Skip to content

v6.0.0-beta01

v6.0.0-beta01 #177

Workflow file for this run

# This is a basic workflow to help you get started with Actions
name: Publish
# Controls when the workflow will run
on:
release:
types: [ published ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
registry_name: ghcr.io
image_name: iothub-portal
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
name: Build & Push Solution
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4.2.2
- id: docker-tag
uses: yuya-takeyama/docker-tag-from-github-ref-action@v1
- name: Configure AWS credentials
id: aws-credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# Should use us-east-1 region to push to ECR public registry
aws-region: us-east-1
- name: Docker Login to ACR
# You may pin to the exact commit or the version.
uses: docker/login-action@v3.3.0
with:
registry: ${{ env.registry_name }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
with:
registry-type: public
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
${{ env.registry_name }}/${{ github.repository_owner }}/${{ env.image_name }}
${{ steps.login-ecr.outputs.registry }}/cgi-fr/${{ env.image_name }}
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
flavor: |
latest=true
- name: Build and push
# You may pin to the exact commit or the version.
uses: docker/build-push-action@v6.9.0
with:
# Build's context is the set of files located in the specified PATH or URL
context: src/
# Push is a shorthand for --output=type=registry
push: true
build-args: |
BUILD_VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
GITHUB_RUN_NUMBER=${{ github.run_number }}
tags:
${{ steps.meta.outputs.tags }}
arm_templates:
name: Publish cloud infrastructure templates
# The type of runner that the job will run on
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.2.2
- name: Get semver
id: version
uses: docker/metadata-action@v5
with:
images: |
${{ env.registry_name }}/${{ github.repository_owner }}/${{ env.image_name }}
tags: |
type=semver,pattern={{version}}
- uses: actions/checkout@v4.2.2
with:
path: IoT-Hub-Portal
submodules: recursive
- uses: actions/checkout@v4.2.2
with:
ref: arm/main
path: arm-templates
- name: Generate app token
id: generate_app_token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.BOT_APP_ID }}
private_key: ${{ secrets.BOT_PRIVATE_KEY }}
- name: Copy templates
working-directory: arm-templates
run: |
rm -rf ./templates/
mkdir -p templates/azure/iotedge-lorawan-starterkit
touch ./templates/.gitkeep
cp -r ../IoT-Hub-Portal/templates/* ./templates/
rm -rf ./templates/iotedge-lorawan-starterkit/
cp -r ../IoT-Hub-Portal/templates/iotedge-lorawan-starterkit/TemplateBicep/* ./templates/azure/iotedge-lorawan-starterkit/
sed -r -i 's/..\/iotedge-lorawan-starterkit\/TemplateBicep\/main.bicep/.\/iotedge-lorawan-starterkit\/main.bicep/g' ./templates/azure/portal_with_lorawan_and_starter_kit.bicep
- name: Update IoTHub Portal docker image tag in app_service.bicep
working-directory: arm-templates/templates/azure
run: sed -i 's/ghcr.io\/cgi-fr\/iothub-portal:latest/ghcr.io\/cgi-fr\/iothub-portal:${{ fromJSON(steps.version.outputs.json).labels['org.opencontainers.image.version'] }}/g' app_service.bicep
- name: Update IoTHub Portal docker image tag in awsdeploy.yml
working-directory: arm-templates/templates/aws
run: |
sed -i 's/public.ecr.aws\/cgi-fr\/iothub-portal:latest/public.ecr.aws\/cgi-fr\/iothub-portal:${{ fromJSON(steps.version.outputs.json).labels['org.opencontainers.image.version'] }}/g' awsdeploy.yml
- name: Generate ARM file
working-directory: arm-templates/templates/azure
run: az bicep build --file azuredeploy.bicep --outfile azuredeploy.json
- name: Upload azure templates to release assets
uses: AButler/upload-release-assets@v3.0
with:
files: 'arm-templates/templates/azure/*.json'
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload aws templates to release assets
uses: AButler/upload-release-assets@v3.0
with:
files: 'arm-templates/templates/aws/*.yml'
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Create PR for template updates
uses: peter-evans/create-pull-request@v7
with:
base: 'arm/main'
branch: 'arm/feature/update-templates'
path: 'arm-templates'
commit-message: 'Update templates from release.'
token: ${{ steps.generate_app_token.outputs.token }}
title: '[ARM Templates] Update templates from release'
labels: |
arm-templates
automated pr
body: |
Automated changes to the Azure templates.