Skip to content

Deploy to environment #1341

Deploy to environment

Deploy to environment #1341

name: Deploy to environment
on:
push:
branches:
- main
workflow_dispatch:
inputs:
environment:
type: environment
description: "Choose an environment to deploy to"
required: true
concurrency:
group: ${{ github.workflow }}-${{ github.event.inputs.environment }}-${{ github.run_number }}
jobs:
set-env:
name: Determine environment
runs-on: ubuntu-22.04
outputs:
environment: ${{ steps.var.outputs.environment }}
branch: ${{ steps.var.outputs.branch }}
checked-out-sha: ${{ steps.var.outputs.checked-out-sha }}
date: ${{ steps.var.outputs.date }}
steps:
- name: Checkout
uses: actions/checkout@v4
- id: var
run: |
GIT_REF=${{ github.ref_name }}
GIT_BRANCH=${GIT_REF##*/}
INPUT=${{ github.event.inputs.environment }}
ENVIRONMENT=${INPUT:-"development"}
CHECKED_OUT_SHA="$(git log -1 '--format=format:%H')"
TIME="$(date)"
echo "environment=${ENVIRONMENT,,}" >> $GITHUB_OUTPUT
echo "branch=$GIT_BRANCH" >> $GITHUB_OUTPUT
echo "checked-out-sha=${CHECKED_OUT_SHA}" >> $GITHUB_OUTPUT
echo "date=${TIME}" >> $GITHUB_OUTPUT
deploy-image:
permissions:
id-token: write
contents: read
packages: write
name: Deploy '${{ needs.set-env.outputs.branch }}' to ${{ needs.set-env.outputs.environment }}
needs: [ set-env ]
uses: DFE-Digital/deploy-azure-container-apps-action/.github/workflows/build-push-deploy.yml@v3.1.0
strategy:
matrix:
suffix: [
"",
"-worker"
]
include:
- suffix: ""
aca_name: "ACA_CONTAINERAPP_NAME"
aca_client_id: "ACA_CLIENT_ID"
- suffix: "-worker"
aca_name: "ACA_CONTAINERAPP_WORKER_NAME"
aca_client_id: "ACA_WORKER_CLIENT_ID"
with:
docker-image-name: 'complete-app'
docker-build-file-name: './Dockerfile'
environment: ${{ needs.set-env.outputs.environment }}
docker-build-args: |
RAILS_ENV=development
CURRENT_GIT_SHA="${{ needs.set-env.outputs.checked-out-sha }}"
TIME_OF_BUILD="${{ needs.set-env.outputs.date }}"
annotate-release: ${{ matrix.suffix == '' }}
secrets:
azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
azure-subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
azure-acr-client-id: ${{ secrets.ACR_CLIENT_ID }}
azure-acr-name: ${{ secrets.ACR_NAME }}
azure-aca-client-id: ${{ secrets[matrix.aca_client_id] }}
azure-aca-name: ${{ secrets[matrix.aca_name] }}
azure-aca-resource-group: ${{ secrets.ACA_RESOURCE_GROUP }}