Terraform Deploy #26
This file contains hidden or 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: Terraform Deploy | |
| on: | |
| workflow_run: | |
| workflows: ["Terraform Build"] | |
| types: [ completed ] | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| actions: read | |
| contents: read | |
| if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
| steps: | |
| - name: Download Terraform plan artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: terraform-plan | |
| path: backend | |
| - name: Checkout triggering commit | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: ${{ github.repository }} | |
| ref: ${{ github.event.workflow_run.head_commit.id }} | |
| - name: Set Azure Credentials | |
| run: | | |
| echo '${{ secrets.AZURE_CREDENTIALS }}' > creds.json | |
| echo "ARM_CLIENT_ID=$(jq -r .clientId creds.json)" >> $GITHUB_ENV | |
| echo "ARM_CLIENT_SECRET=$(jq -r .clientSecret creds.json)" >> $GITHUB_ENV | |
| echo "ARM_SUBSCRIPTION_ID=$(jq -r .subscriptionId creds.json)" >> $GITHUB_ENV | |
| echo "ARM_TENANT_ID=$(jq -r .tenantId creds.json)" >> $GITHUB_ENV | |
| rm -f creds.json | |
| shell: bash | |
| - name: Set up Terraform | |
| uses: hashicorp/setup-terraform@v3 | |
| with: | |
| terraform_version: 1.9.8 | |
| - name: Terraform Init | |
| run: terraform init | |
| working-directory: backend | |
| - name: Terraform Apply | |
| run: terraform apply -auto-approve tfplan | |
| working-directory: backend |