Publish #173
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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@v3.5.3 | |
- id: docker-tag | |
uses: yuya-takeyama/docker-tag-from-github-ref-action@v1 | |
- name: Docker Login | |
# You may pin to the exact commit or the version. | |
uses: docker/login-action@v2.2.0 | |
with: | |
registry: ${{ env.registry_name }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
# list of Docker images to use as base name for tags | |
images: | | |
${{ env.registry_name }}/${{ github.repository_owner }}/${{ 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@v4.1.1 | |
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 ARM templates | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3.5.3 | |
- name: Get semver | |
id: version | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
${{ env.registry_name }}/${{ github.repository_owner }}/${{ env.image_name }} | |
tags: | | |
type=semver,pattern={{version}} | |
- uses: actions/checkout@v3.5.3 | |
with: | |
path: IoT-Hub-Portal | |
- name: Checkout Azure/iotedge-lorawan-starterkit | |
uses: actions/checkout@v3.5.3 | |
with: | |
repository: Azure/iotedge-lorawan-starterkit | |
ref: dev | |
path: iotedge-lorawan-starterkit | |
- uses: actions/checkout@v3.5.3 | |
with: | |
ref: arm/main | |
path: arm-templates | |
- name: Generate app token | |
id: generate_app_token | |
uses: tibdex/github-app-token@v1 | |
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/iotedge-lorawan-starterkit | |
touch ./templates/.gitkeep | |
cp -r ../IoT-Hub-Portal/templates/* ./templates/ | |
cp -r ../iotedge-lorawan-starterkit/TemplateBicep/* ./templates/iotedge-lorawan-starterkit/ | |
sed -r -i 's/..\/iotedge-lorawan-starterkit\/TemplateBicep\/main.bicep/.\/iotedge-lorawan-starterkit\/main.bicep/g' ./templates/portal_with_lorawan_and_starter_kit.bicep | |
- name: Update IoTHub Portal docker image tag in app_service.bicep | |
working-directory: arm-templates/templates | |
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: Generate ARM file | |
working-directory: arm-templates/templates | |
run: az bicep build --file azuredeploy.bicep --outfile azuredeploy.json | |
- name: Upload templates to release assets | |
uses: AButler/upload-release-assets@v2.0 | |
with: | |
files: 'arm-templates/templates/*.json' | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create PR for template updates | |
uses: peter-evans/create-pull-request@v5 | |
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. |