refactor(ci): deploy workflow #8
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: PR validation | |
concurrency: | |
group: ${{ github.event.number }} | |
cancel-in-progress: false | |
on: | |
pull_request: | |
branches: | |
- main | |
permissions: | |
id-token: write | |
contents: read | |
env: | |
resourceGroupName: pr_${{ github.event.number }} | |
resourceGroupLocation: westeurope | |
# https://learn.microsoft.com/en-us/training/modules/automate-azure-infrastructure-change-reviews-using-bicep-github/6-exercise-create-ephemeral-environments-pull-requests | |
jobs: | |
lint-infra: | |
name: Lint infrastructure | |
uses: ./.github/workflows/lint.yml | |
build-app: | |
name: Build application | |
uses: ./.github/workflows/build.yml | |
create-rg: | |
name: Create resource group | |
runs-on: ubuntu-latest | |
environment: test | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Login to Azure | |
uses: azure/login@v2 | |
with: | |
client-id: ${{ secrets.AZURE_CLIENT_ID }} | |
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | |
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
- uses: azure/cli@v2 | |
name: Create resource group | |
with: | |
inlineScript: | | |
az group create \ | |
--name ${{ env.resourceGroupName }} \ | |
--location ${{ env.resourceGroupLocation }} | |
needs: [lint-infra, build-app] | |
deploy: | |
name: Deploy | |
uses: ./.github/workflows/deploy.yml | |
with: | |
environment: test | |
resourceGroupName: pr_${{ github.event.number }} | |
secrets: | |
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} | |
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} | |
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
needs: [create-rg] |