|
| 1 | +name: Runtime - deploy apps config |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + paths: |
| 8 | + - infra/runtime/apps-config/** |
| 9 | + - .github/workflows/deploy-runtime-apps-config.yaml |
| 10 | + workflow_dispatch: |
| 11 | + inputs: |
| 12 | + rings: |
| 13 | + description: 'Rings to tag the artifact with. Format of the input object is [{"ring": "at_ring1", "environment": "runtime_at_ring1"}].' |
| 14 | + required: false |
| 15 | + default: '[{"ring": "at_ring1", "environment": "runtime_at_ring1"}]' |
| 16 | + |
| 17 | +permissions: |
| 18 | + id-token: write |
| 19 | + contents: read |
| 20 | + |
| 21 | +jobs: |
| 22 | + get-short-sha: |
| 23 | + uses: ./.github/workflows/template-short-sha.yaml |
| 24 | + |
| 25 | + construct-rings-array: |
| 26 | + runs-on: ubuntu-latest |
| 27 | + env: |
| 28 | + default-rings: >- |
| 29 | + [{"ring": "at_ring1", "environment": "runtime_at_ring1"},{"ring": "at_ring2", "environment": "runtime_at_ring2"},{"ring": "tt_ring1", "environment": "runtime_tt_ring1"},{"ring": "tt_ring2", "environment": "runtime_tt_ring2"},{"ring": "prod_ring1", "environment": "runtime_prod_ring1"},{"ring": "prod_ring2", "environment": "runtime_prod_ring2"}] |
| 30 | + outputs: |
| 31 | + ringsjson: ${{ steps.construct-rings.outputs.ringsjson }} |
| 32 | + steps: |
| 33 | + - name: Construct rings array |
| 34 | + id: construct-rings |
| 35 | + run: | |
| 36 | + rings='${{ github.event.inputs.rings }}' |
| 37 | + if [ -z "$rings" ]; then |
| 38 | + rings='${{ env.default-rings }}' |
| 39 | + fi |
| 40 | + echo "Raw rings input: $rings" |
| 41 | + echo "ringsjson=${rings}" >> $GITHUB_OUTPUT |
| 42 | +
|
| 43 | + push-apps-config-artifact: |
| 44 | + name: Push apps config as OCI artifact |
| 45 | + needs: get-short-sha |
| 46 | + runs-on: ubuntu-latest |
| 47 | + environment: dev |
| 48 | + env: |
| 49 | + REGISTRY_NAME: altinncr |
| 50 | + CONFIG_REPO: altinncr.azurecr.io/studio-apps/runtime-apps-config-repo:${{ needs.get-short-sha.outputs.short-sha }} |
| 51 | + outputs: |
| 52 | + config-repo: altinncr.azurecr.io/studio-apps/runtime-apps-config-repo:${{ needs.get-short-sha.outputs.short-sha }} |
| 53 | + defaults: |
| 54 | + run: |
| 55 | + working-directory: infra/runtime/apps-config |
| 56 | + steps: |
| 57 | + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 |
| 58 | + |
| 59 | + - name: az login |
| 60 | + uses: azure/login@a457da9ea143d694b1b9c7c869ebb04ebe844ef5 # v2 |
| 61 | + with: |
| 62 | + client-id: ${{ secrets.AZURE_CLIENT_ID_FC }} |
| 63 | + tenant-id: ${{ secrets.AZURE_TENANT_ID_FC }} |
| 64 | + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID_FC }} |
| 65 | + |
| 66 | + - name: az acr login |
| 67 | + run: az acr login --name ${{ env.REGISTRY_NAME }} |
| 68 | + |
| 69 | + - name: flux install |
| 70 | + uses: fluxcd/flux2/action@8454b02a32e48d775b9f563cb51fdcb1787b5b93 # v2.7.5 |
| 71 | + |
| 72 | + - name: push artifact |
| 73 | + run: | |
| 74 | + flux push artifact oci://${{ env.CONFIG_REPO }} \ |
| 75 | + --provider=azure \ |
| 76 | + --reproducible \ |
| 77 | + --path="." \ |
| 78 | + --source="$(git config --get remote.origin.url)" \ |
| 79 | + --revision="$(git branch --show-current)/$(git rev-parse HEAD)" |
| 80 | +
|
| 81 | + tag-apps-config: |
| 82 | + name: Tag apps config |
| 83 | + needs: [push-apps-config-artifact, construct-rings-array] |
| 84 | + runs-on: ubuntu-latest |
| 85 | + environment: ${{ matrix.environment }} |
| 86 | + strategy: |
| 87 | + matrix: |
| 88 | + include: ${{ fromJson(needs.construct-rings-array.outputs.ringsjson) }} |
| 89 | + steps: |
| 90 | + - name: az login |
| 91 | + uses: azure/login@a457da9ea143d694b1b9c7c869ebb04ebe844ef5 # v2 |
| 92 | + with: |
| 93 | + client-id: ${{ secrets.AZURE_CLIENT_ID_FC }} |
| 94 | + tenant-id: ${{ secrets.AZURE_TENANT_ID_FC }} |
| 95 | + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID_FC }} |
| 96 | + |
| 97 | + - name: az acr login |
| 98 | + run: az acr login --name altinncr |
| 99 | + |
| 100 | + - name: flux install |
| 101 | + uses: fluxcd/flux2/action@8454b02a32e48d775b9f563cb51fdcb1787b5b93 # v2.7.5 |
| 102 | + |
| 103 | + - name: tag artifact |
| 104 | + run: | |
| 105 | + flux tag artifact oci://${{ needs.push-apps-config-artifact.outputs.config-repo }} \ |
| 106 | + --tag ${{ matrix.ring }} |
0 commit comments