Skip to content

Initial push of the changes to render the additional information. (#… #148

Initial push of the changes to render the additional information. (#…

Initial push of the changes to render the additional information. (#… #148

name: Main build & deploy
on:
workflow_dispatch:
push:
branches: ["main"]
paths:
- 'src/**'
- '.github/workflows/main-build-and-deploy.yml'
jobs:
set-env:
runs-on: ubuntu-22.04
name: Set Environment Values
outputs:
branch: ${{ steps.var.outputs.branch }}
checked-out-sha: ${{ steps.var.outputs.checked-out-sha }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- id: var
run: |
GIT_BRANCH=${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}
CHECKED_OUT_SHA="$(git log -1 '--format=format:%H')"
echo "branch=$GIT_BRANCH" >> $GITHUB_OUTPUT
echo "checked-out-sha=${CHECKED_OUT_SHA}" >> $GITHUB_OUTPUT
create-and-publish-image:
needs: set-env
name: Create & Publish Image
uses: ./.github/workflows/build-image.yml
secrets: inherit
with:
branch: ${{ needs.set-env.outputs.branch }}
checked-out-sha: ${{ needs.set-env.outputs.checked-out-sha }}
deploy-to-dev:
runs-on: ubuntu-22.04
needs: create-and-publish-image
name: Deploy to development
environment: development
# Permissions for OIDC authentication
permissions:
id-token: write
contents: write
issues: write
steps:
- name: Check out repository
uses: actions/checkout@v4
# Login to Azure using OIDC
- name: Login to Azure CLI
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
# Deploy Web Application to slot
- name: Deploy to Azure App Services slot
uses: azure/webapps-deploy@v3
with:
app-name: ${{ vars.WEBAPP_NAME }}
images: ${{ needs.create-and-publish-image.outputs.dockerImageTag }}
slot-name: "${{ vars.WEBAPP_SLOT_NAME }}"
# Make a request to the health check endpoint
- name: Make request to health check endpoint
uses: ./.github/actions/health-check
with:
webapp_name: ${{ vars.WEBAPP_NAME }}
slot_name: ${{ vars.WEBAPP_SLOT_NAME }}
# Swap the slots
- name: Swap to the production slot
run: |
az webapp deployment slot swap --resource-group ${{ vars.RESOURCE_NAME_PREFIX }}-rg --name ${{ vars.WEBAPP_NAME }} --slot ${{ vars.WEBAPP_SLOT_NAME }} --target-slot production
deploy-to-staging:
runs-on: ubuntu-22.04
needs: [create-and-publish-image, deploy-to-dev]
name: Deploy to staging
environment: staging
# Permissions for OIDC authentication
permissions:
id-token: write
contents: write
issues: write
steps:
- name: Check out repository
uses: actions/checkout@v4
# Login to Azure using OIDC
- name: Login to Azure CLI
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
# Deploy Web Application
- name: Deploy to Azure App Services
uses: azure/webapps-deploy@v3
with:
app-name: ${{ vars.WEBAPP_NAME }}
images: ${{ needs.create-and-publish-image.outputs.dockerImageTag }}
slot-name: "${{ vars.WEBAPP_SLOT_NAME }}"
# Make a request to the health check endpoint
- name: Make request to health check endpoint
uses: ./.github/actions/health-check
with:
webapp_name: ${{ vars.WEBAPP_NAME }}
slot_name: ${{ vars.WEBAPP_SLOT_NAME }}
# Swap the slots
- name: Swap to the production slot
run: |
az webapp deployment slot swap --resource-group ${{ vars.RESOURCE_NAME_PREFIX }}-rg --name ${{ vars.WEBAPP_NAME }} --slot ${{ vars.WEBAPP_SLOT_NAME }} --target-slot production
deploy-to-production:
runs-on: ubuntu-22.04
needs: [create-and-publish-image, deploy-to-staging]
name: Deploy to production
environment: production
# Permissions for OIDC authentication
permissions:
id-token: write
contents: write
issues: write
steps:
- name: Check out repository
uses: actions/checkout@v4
# Login to Azure using OIDC
- name: Login to Azure CLI
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
# Deploy Web Application
- name: Deploy to Azure App Services
uses: azure/webapps-deploy@v3
with:
app-name: ${{ vars.WEBAPP_NAME }}
images: ${{ needs.create-and-publish-image.outputs.dockerImageTag }}
slot-name: "${{ vars.WEBAPP_SLOT_NAME }}"
# Make a request to the health check endpoint
- name: Make request to health check endpoint
uses: ./.github/actions/health-check
with:
webapp_name: ${{ vars.WEBAPP_NAME }}
slot_name: ${{ vars.WEBAPP_SLOT_NAME }}
# Swap the slots
- name: Swap to the production slot
run: |
az webapp deployment slot swap --resource-group ${{ vars.RESOURCE_NAME_PREFIX }}-rg --name ${{ vars.WEBAPP_NAME }} --slot ${{ vars.WEBAPP_SLOT_NAME }} --target-slot production