Merge pull request #10 from chris-kruining/feature/container-apps #18
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
name: Publish to registry | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
prepare: | |
name: Calculate next version | |
runs-on: ubuntu-latest | |
outputs: | |
major: ${{ steps.gitversion.outputs.Major }} | |
minor: ${{ steps.gitversion.outputs.Minor }} | |
patch: ${{ steps.gitversion.outputs.Patch }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/[email protected] | |
with: | |
versionSpec: "5.x" | |
- name: Determine Version | |
id: gitversion | |
uses: gittools/actions/gitversion/[email protected] | |
with: | |
useConfigFile: true | |
infra: | |
name: Infrastructure | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
sparse-checkout: | | |
infrastructure | |
- name: Az CLI login | |
uses: azure/login@v2 | |
with: | |
client-id: ${{ secrets.TRICEP_CLIENT_ID }} | |
tenant-id: ${{ secrets.TRICEP_TENANT_ID }} | |
subscription-id: ${{ secrets.TRICEP_SUBSCRIPTION_ID }} | |
- name: Deploy bicep | |
uses: Azure/cli@v2 | |
with: | |
inlineScript: | | |
az deployment sub create \ | |
--location westeurope \ | |
--template-file infrastructure/main.bicep \ | |
--parameters infrastructure/params/main.prd.bicepparam | |
publish: | |
name: Publish | |
runs-on: ubuntu-latest | |
needs: [ prepare, infra ] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
sparse-checkout: | | |
src | |
- name: Az CLI login | |
uses: azure/login@v2 | |
with: | |
client-id: ${{ secrets.TRICEP_CLIENT_ID }} | |
tenant-id: ${{ secrets.TRICEP_TENANT_ID }} | |
subscription-id: ${{ secrets.TRICEP_SUBSCRIPTION_ID }} | |
- name: Publish Bicep module | |
uses: azure/cli@v2 | |
with: | |
inlineScript: | | |
cd src | |
for x in $(find . -name internal -prune -o -type f -name "*.bicep" -print); do | |
name=${x#"./"} | |
name=${name%".bicep"} | |
name="br:${{ secrets.ACR_LOGIN_SERVER }}/$name" | |
label="${{ fromJson('{"true": "latest","false":"next"}')[github.ref == 'refs/heads/main'] }}" | |
major="${{needs.prepare.outputs.major}}" | |
minor="${{needs.prepare.outputs.minor}}" | |
patch="${{needs.prepare.outputs.patch}}" | |
az bicep publish --file "$x" --target "$name:$label" --with-source --force | |
if ["${{github.ref}}" = "refs/heads/main"]; then | |
az bicep publish --file "$x" --target "$name:$major" --with-source --force | |
az bicep publish --file "$x" --target "$name:$major.$minor" --with-source --force | |
az bicep publish --file "$x" --target "$name:$major.$minor.$patch" --with-source | |
fi | |
done | |