Skip to content

Commit

Permalink
Deploy to environments from dispatch (#13347)
Browse files Browse the repository at this point in the history
* try using dev environment from feature branch

* use usual designer deploy pipeline

* output environments

* try fix default environments

* fix echo of environment

* fix determined tag

* try deploy to dev from feature branch

* include environment in docker pipeline

* set type for environment parameter

* try to deploy to dev from feature branch

* try to deploy to dev from feature branch
  • Loading branch information
mirkoSekulic authored and standeren committed Aug 15, 2024
1 parent 7ca686d commit 5f99113
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 9 deletions.
54 changes: 45 additions & 9 deletions .github/workflows/deploy-designer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ on:
- 'charts/altinn-designer-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
Expand All @@ -25,44 +30,75 @@ jobs:
get-short-sha:
uses: ./.github/workflows/template-short-sha.yaml

docker-build-push:
construct-environments-array:
needs: get-short-sha
runs-on: ubuntu-latest
outputs:
environmentsjson: ${{ steps.construct-enviornments.outputs.environmentsjson }}
steps:
- name: Construct environment
id: construct-enviornments
run: |
environments="${{ github.event.inputs.environments || 'dev,staging,prod' }}"
jsonArray=$(echo "[\"$(echo $environments | sed 's/,/\",\"/g')\"]")
echo "environmentsjson=${jsonArray}" >> $GITHUB_OUTPUT
determine-tag:
needs: get-short-sha
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.determine-tag.outputs.tag }}
steps:
- name: Determine tag
id: determine-tag
run: |
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
echo "tag=${{ needs.get-short-sha.outputs.short-sha }}" >> $GITHUB_OUTPUT
else
sanitized_branch_name=$(echo "${{ github.ref_name }}" | tr '/' '-')
echo "tag=${sanitized_branch_name}-${{ needs.get-short-sha.outputs.short-sha }}" >> $GITHUB_OUTPUT
fi
docker-build-push:
needs: [get-short-sha, determine-tag]
uses: ./.github/workflows/template-docker-push.yaml
with:
tags: ${{ needs.get-short-sha.outputs.short-sha }},latest
tags: ${{ needs.determine-tag.outputs.tag }},latest
registry-name: altinntjenestercontainerregistry.azurecr.io
repository-name: altinn-core
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 }}
build-args: DESIGNER_VERSION=${{ needs.get-short-sha.outputs.short-sha }}
build-args: DESIGNER_VERSION=${{ needs.determine-tag.outputs.tag }}

helm-push:
needs: get-short-sha
needs: [get-short-sha, determine-tag]
uses: ./.github/workflows/template-helm-push.yaml
with:
tag: 0.1.0+${{ needs.get-short-sha.outputs.short-sha }} # Helm version needs to be valid sematic version
tag: 0.1.0+${{ needs.determine-tag.outputs.tag }} # Helm version needs to be valid sematic version
chart-name: altinn-designer
registry-name: altinntjenestercontainerregistry.azurecr.io
environment: dev
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: [get-short-sha, docker-build-push, helm-push]
needs: [construct-environments-array, determine-tag, docker-build-push, helm-push]
strategy:
matrix:
environment: [dev, staging, prod]
environment: ${{ fromJSON(needs.construct-environments-array.outputs.environmentsjson) }}
uses: ./.github/workflows/template-flux-config-push.yaml
with:
tag: ${{ needs.get-short-sha.outputs.short-sha }}
tag: ${{ needs.determine-tag.outputs.tag }}
registry-name: altinntjenestercontainerregistry.azurecr.io
environment: ${{ matrix.environment }}
config-chart-name: altinn-designer-config
artifact-name: altinn-designer
helm-set-arguments: environmentName=${{ matrix.environment }},chartVersion=0.1.0+${{ needs.get-short-sha.outputs.short-sha }},imageTag=${{ needs.get-short-sha.outputs.short-sha }}
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 }}
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/template-docker-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ on:
repository-name:
required: true
type: string
environment:
required: false
type: string
default: ''

secrets:
client-id:
Expand All @@ -35,6 +39,7 @@ jobs:
docker-build-push:
name: Build and push docker image
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
steps:
- uses: actions/checkout@v4

Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/template-helm-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ on:
registry-name:
required: true
type: string
environment:
required: false
type: string
default: ''

secrets:
client-id:
Expand All @@ -25,6 +29,7 @@ jobs:
helm-build-push:
name: Helm build and push
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
steps:
- uses: actions/checkout@v4

Expand Down

0 comments on commit 5f99113

Please sign in to comment.