Skip to content

Commit

Permalink
Merge pull request #21 from DFE-Digital/workflow/deployment-to-azure
Browse files Browse the repository at this point in the history
Build and deploy a Container Image to Azure Container Apps
  • Loading branch information
sukhybhullar-nimble authored Dec 18, 2024
2 parents 6d2d041 + 7316eae commit 2546040
Showing 1 changed file with 90 additions and 0 deletions.
90 changes: 90 additions & 0 deletions .github/workflows/build-and-push-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Deploy

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 }}

jobs:
set-env:
name: Determine environment
runs-on: ubuntu-latest
outputs:
environment: ${{ steps.var.outputs.environment }}
release: ${{ steps.var.outputs.release }}
steps:
- name: Checkout
uses: actions/checkout@v4

- id: var
run: |
INPUT=${{ github.event.inputs.environment }}
ENVIRONMENT=${INPUT:-"development"}
RELEASE=${ENVIRONMENT,,}-`date +%Y-%m-%d`.${{ github.run_number }}
echo "environment=${ENVIRONMENT,,}" >> $GITHUB_OUTPUT
echo "release=${RELEASE}" >> $GITHUB_OUTPUT
deploy-image:
permissions:
id-token: write
contents: read
packages: write
name: Deploy Container
needs: [ set-env ]
uses: DFE-Digital/deploy-azure-container-apps-action/.github/workflows/[email protected]
with:
docker-tag-prefix: dotnet
docker-image-name: 'complete-app'
docker-build-file-name: './Dockerfile'
environment: ${{ needs.set-env.outputs.environment }}
annotate-release: false
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.ACA_CLIENT_ID }}
azure-aca-name: ${{ secrets.ACA_CONTAINERAPP_NAME }}
azure-aca-resource-group: ${{ secrets.ACA_RESOURCE_GROUP }}

create-tag:
name: Tag and release
needs: [ set-env, deploy-image ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

- name: Create tag
run: |
git tag ${{ needs.set-env.outputs.release }}
git push origin ${{ needs.set-env.outputs.release }}
- name: Create release
uses: "actions/github-script@v7"
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
script: |
try {
await github.rest.repos.createRelease({
draft: false,
generate_release_notes: true,
name: "${{ needs.set-env.outputs.release }}",
owner: context.repo.owner,
prerelease: false,
repo: context.repo.repo,
tag_name: "${{ needs.set-env.outputs.release }}",
});
} catch (error) {
core.setFailed(error.message);
}

0 comments on commit 2546040

Please sign in to comment.