Skip to content

chore: short-sha workflow to simple GITHUB_SHA refs (#18332) #122

chore: short-sha workflow to simple GITHUB_SHA refs (#18332)

chore: short-sha workflow to simple GITHUB_SHA refs (#18332) #122

name: Deploy Repositories
on:
push:
branches: [ main ]
paths:
- '.github/workflows/deploy-repositories.yaml'
- '.github/workflows/template-docker-push.yaml'
- '.github/workflows/template-flux-config-push.yaml'
- '.github/workflows/template-helm-push.yaml'
- 'src/gitea/**'
- 'src/gitea-proxy/**'
- 'charts/altinn-repositories/**'
- 'charts/altinn-repositories-config/**'
workflow_dispatch:
inputs:
environments:
description: 'Environments to deploy to. Multiple environments can be specified by separating them with a comma.'
required: false
default: 'dev'
permissions:
id-token: write
contents: read
jobs:
construct-environments-array:
uses: ./.github/workflows/template-studio-construct-environments.yaml
with:
inputs: ${{ toJSON(github.event.inputs) }}
determine-tag:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.determine-tag.outputs.tag }}
steps:
- name: Determine tag
id: determine-tag
run: |
SHORT_SHA="${GITHUB_SHA::10}"
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
echo "tag=${SHORT_SHA}" >> "$GITHUB_OUTPUT"
else
sanitized_branch_name=$(echo "${{ github.ref_name }}" | tr -d '()' | tr '/' '-')
echo "tag=${sanitized_branch_name}-${SHORT_SHA}" >> "$GITHUB_OUTPUT"
fi
docker-build-push:
needs: determine-tag
uses: ./.github/workflows/template-docker-push.yaml
with:
tags: ${{ needs.determine-tag.outputs.tag }},latest
registry-name: altinntjenestercontainerregistry.azurecr.io
repository-name: altinn-repositories
context: src/gitea
dockerfile: src/gitea/Dockerfile
environment: dev # dev environment has push access and doesn't require review
secrets:
client-id: ${{ secrets.AZURE_CLIENT_ID_FC }}
tenant-id: ${{ secrets.AZURE_TENANT_ID_FC }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID_FC }}
docker-build-push-gitea-proxy:
needs: determine-tag
uses: ./.github/workflows/template-docker-push.yaml
with:
tags: ${{ needs.determine-tag.outputs.tag }},latest
registry-name: altinntjenestercontainerregistry.azurecr.io
repository-name: altinn-gitea-proxy
context: src/gitea-proxy
dockerfile: src/gitea-proxy/Dockerfile
environment: dev
secrets:
client-id: ${{ secrets.AZURE_CLIENT_ID_FC }}
tenant-id: ${{ secrets.AZURE_TENANT_ID_FC }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID_FC }}
helm-push:
needs: determine-tag
uses: ./.github/workflows/template-helm-push.yaml
with:
tag: 0.1.0+${{ needs.determine-tag.outputs.tag }} # Helm version needs to be valid semantic version
chart-name: altinn-repositories
registry-name: altinntjenestercontainerregistry.azurecr.io
environment: dev # dev environment has push access and doesn't require review
secrets:
client-id: ${{ secrets.AZURE_CLIENT_ID_FC }}
tenant-id: ${{ secrets.AZURE_TENANT_ID_FC }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID_FC }}
flux-config-push:
needs: [construct-environments-array, determine-tag, docker-build-push, docker-build-push-gitea-proxy, helm-push]
strategy:
matrix:
include: ${{ fromJSON(needs.construct-environments-array.outputs.result) }}
uses: ./.github/workflows/template-flux-config-push.yaml
with:
tag: ${{ needs.determine-tag.outputs.tag }}
registry-name: altinntjenestercontainerregistry.azurecr.io
environment: ${{ matrix.environment }}
config-chart-name: altinn-repositories-config
artifact-name: altinn-repositories
helm-set-arguments: environmentName=${{ matrix.environment }},chartVersion=0.1.0+${{ needs.determine-tag.outputs.tag }},imageTag=${{ needs.determine-tag.outputs.tag }}
secrets:
client-id: ${{ secrets.AZURE_CLIENT_ID_FC }}
tenant-id: ${{ secrets.AZURE_TENANT_ID_FC }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID_FC }}