Skip to content

Release to Production #253

Release to Production

Release to Production #253

name: Release to Production
on:
workflow_dispatch:
push:
branches:
- main
schedule:
- cron: "0 3 * * 4" # Every Thursday at 3am
permissions:
id-token: write # This is required for Az CLI Login
contents: read # This is required for actions/checkout
concurrency: # This is required to prevent multiple runs of the same workflow from running at the same time.
group: ${{ github.workflow }}
jobs:
dotnet-func-ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: frasermolyneux/actions/dotnet-func-ci@main
with:
dotnet-project: "event-ingest-func"
dotnet-version: 9.0.x
src-folder: "src"
majorMinorVersion: "1.1"
publish-nuget-packages:
environment: NuGet
runs-on: ubuntu-latest
needs: [dotnet-func-ci]
steps:
- uses: actions/checkout@v4
- uses: frasermolyneux/actions/publish-nuget-packages@main
with:
artifact-name: "nuget-packages"
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
terraform-plan-and-apply-dev:
environment: Development
runs-on: ubuntu-latest
concurrency: # This is required to prevent multiple GitHub Actions invocations against stateful resources. e.g. Terraform state file / Database / Deployed Apps
group: ${{ github.repository }}-dev
steps:
- uses: actions/checkout@v4
- uses: frasermolyneux/actions/terraform-plan-and-apply@main
with:
terraform-folder: "terraform"
terraform-var-file: "tfvars/dev.tfvars"
terraform-backend-file: "backends/dev.backend.hcl"
AZURE_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ vars.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }}
- id: terraform-output
shell: bash
run: |
cd terraform
echo "function_app_name=$(terraform output -raw function_app_name)" >> $GITHUB_OUTPUT
env:
ARM_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }}
ARM_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }}
ARM_TENANT_ID: ${{ vars.AZURE_TENANT_ID }}
ARM_USE_AZUREAD: true
ARM_USE_OIDC: true
outputs:
function_app_name: ${{ steps.terraform-output.outputs.function_app_name }}
function-app-deploy-dev:
environment: Development
runs-on: ubuntu-latest
needs: [dotnet-func-ci, terraform-plan-and-apply-dev]
concurrency: # This is required to prevent multiple GitHub Actions invocations against stateful resources. e.g. Terraform state file / Database / Deployed Apps
group: ${{ github.repository }}-dev
steps:
- uses: actions/checkout@v4
- uses: frasermolyneux/actions/deploy-function-app@main
with:
function-app-artifact-name: "event-ingest-func"
function-app-name: ${{ needs.terraform-plan-and-apply-dev.outputs.function_app_name }}
AZURE_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ vars.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }}
terraform-plan-and-apply-prd:
environment: Production
runs-on: ubuntu-latest
needs: [function-app-deploy-dev]
concurrency: # This is required to prevent multiple GitHub Actions invocations against stateful resources. e.g. Terraform state file / Database / Deployed Apps
group: ${{ github.repository }}-prd
steps:
- uses: actions/checkout@v4
- uses: frasermolyneux/actions/terraform-plan-and-apply@main
with:
terraform-folder: "terraform"
terraform-var-file: "tfvars/prd.tfvars"
terraform-backend-file: "backends/prd.backend.hcl"
AZURE_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ vars.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }}
- id: terraform-output
shell: bash
run: |
cd terraform
echo "function_app_name=$(terraform output -raw function_app_name)" >> $GITHUB_OUTPUT
env:
ARM_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }}
ARM_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }}
ARM_TENANT_ID: ${{ vars.AZURE_TENANT_ID }}
ARM_USE_AZUREAD: true
ARM_USE_OIDC: true
outputs:
function_app_name: ${{ steps.terraform-output.outputs.function_app_name }}
function-app-deploy-prd:
environment: Production
runs-on: ubuntu-latest
needs: [dotnet-func-ci, terraform-plan-and-apply-prd]
concurrency: # This is required to prevent multiple GitHub Actions invocations against stateful resources. e.g. Terraform state file / Database / Deployed Apps
group: ${{ github.repository }}-prd
steps:
- uses: actions/checkout@v4
- uses: frasermolyneux/actions/deploy-function-app@main
with:
function-app-artifact-name: "event-ingest-func"
function-app-name: ${{ needs.terraform-plan-and-apply-prd.outputs.function_app_name }}
AZURE_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ vars.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }}