another concurrency syntax #24
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 'Build, Deploy (all environments)' | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- '*' | |
jobs: | |
build: | |
name: 'Build' | |
runs-on: ubuntu-latest | |
steps: | |
- name: 'Checkout Code' | |
uses: actions/checkout@v4 | |
- name: 'Install dotnet 8.0.x' | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '8.0.x' | |
- name: 'Install .Net (nuget) dependencies' | |
run: | | |
dotnet restore GenderPayGap.Core/GenderPayGap.Core.csproj | |
dotnet restore GenderPayGap.Database/GenderPayGap.Database.csproj | |
dotnet restore GenderPayGap.WebUI/GenderPayGap.WebUI.csproj | |
dotnet restore GenderPayGap.UnitTests/GenderPayGap.WebUI.Tests/GenderPayGap.WebUI.Tests.csproj | |
- name: 'Install Node.JS version 20 (v22 caused an error during npm ci)' | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: 'Install Node.JS (npm) dependencies' | |
run: | | |
npm ci | |
working-directory: GenderPayGap.WebUI | |
- name: 'Build JS and SCSS code' | |
run: | | |
npm run build | |
working-directory: GenderPayGap.WebUI | |
- name: 'Save build run info to JSON file' | |
run: | | |
echo '{ "BuildNumber": "${{ github.run_id }}", "git_commit": "${{ github.sha }}", "git_branch": "${{ github.ref_name }}", "github_action_name": "${{ github.workflow }}", "github_action_run_url": "https://github.com/${{github.repository}}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}" }' > build-number.json | |
working-directory: GenderPayGap.WebUI | |
- name: 'Build .Net code' | |
run: | | |
dotnet build GenderPayGap.WebUI/GenderPayGap.WebUI.csproj | |
- name: 'Test .Net code' | |
run: | | |
dotnet test GenderPayGap.UnitTests/GenderPayGap.WebUI.Tests/GenderPayGap.WebUI.Tests.csproj --logger "trx;LogFileName=test-results.trx" | |
- name: 'Publish .Net test results' | |
uses: dorny/test-reporter@v1 | |
if: ${{ always() }} # Use always() to always run this step to publish test results when there are test failures | |
with: | |
name: 'test-results' | |
path: GenderPayGap.UnitTests/GenderPayGap.WebUI.Tests/TestResults/test-results.trx | |
reporter: dotnet-trx | |
- name: 'Publish .Net code' | |
run: | | |
dotnet publish GenderPayGap.WebUI/GenderPayGap.WebUI.csproj -p:Configuration=Release | |
- name: 'Zip up the code' | |
run: | | |
zip -rq build.zip . | |
working-directory: GenderPayGap.WebUI/bin/Release/net8.0/publish/ | |
- name: 'Save build zip as GitHub Actions artifact' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build-zip | |
path: GenderPayGap.WebUI/bin/Release/net8.0/publish/build.zip | |
terraform_dev: | |
name: 'Terraform (dev)' | |
concurrency: '${{ github.workflow }}--terraform_dev' # Prevents more than one instance of this workflow/job running at the same time (to prevent 2 instances deploying or terraforming at the same time) | |
runs-on: ubuntu-latest | |
needs: [build] | |
environment: dev | |
steps: | |
- name: 'Checkout Code' | |
uses: actions/checkout@v4 | |
deploy_dev: | |
name: 'Deploy (dev)' | |
concurrency: '${{ github.workflow }}--deploy_dev' # Prevents more than one instance of this workflow/job running at the same time (to prevent 2 instances deploying or terraforming at the same time) | |
runs-on: ubuntu-latest | |
needs: [terraform_dev] | |
environment: dev | |
steps: | |
- name: 'Download build zip from GitHub Actions artifacts' | |
uses: actions/download-artifact@v4 | |
with: | |
name: build-zip | |
terraform_prod: | |
name: 'Terraform (prod)' | |
concurrency: '${{ github.workflow }}--terraform_prod' # Prevents more than one instance of this workflow/job running at the same time (to prevent 2 instances deploying or terraforming at the same time) | |
runs-on: ubuntu-latest | |
needs: [build] | |
environment: prod | |
steps: | |
- name: 'Checkout Code' | |
uses: actions/checkout@v4 | |
deploy_prod: | |
name: 'Deploy (prod)' | |
concurrency: '${{ github.workflow }}--deploy_prod' # Prevents more than one instance of this workflow/job running at the same time (to prevent 2 instances deploying or terraforming at the same time) | |
runs-on: ubuntu-latest | |
needs: [terraform_prod] | |
environment: prod | |
steps: | |
- name: 'Download build zip from GitHub Actions artifacts' | |
uses: actions/download-artifact@v4 | |
with: | |
name: build-zip |