Terraform flow #14
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: Terraform flow | |
on: | |
workflow_dispatch: | |
inputs: | |
environment: | |
type: choice | |
description: Which environment you wish to use | |
options: | |
- integration | |
- production | |
resource: | |
type: choice | |
description: Which resource you wish to create | |
options: | |
- key-vault | |
- storage-account | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
build: | |
runs-on: self-hosted | |
environment: ${{ inputs.environment }} | |
env: | |
WORK_DIR: ${{ inputs.environment }}/${{ inputs.resource }}/ | |
ARM_SUBSCRIPTION_ID: ${{ inputs.environment == 'integration' && secrets.SUBSCRIPTION_ID || secrets.SUBSCRIPTION_ID_PROD}} | |
ARM_TENANT_ID: ${{ secrets.TENANT_ID }} | |
ARM_CLIENT_ID: ${{ inputs.environment == 'integration' && secrets.CLIENT_ID || secrets.CLIENT_ID_PROD}} | |
ARM_CLIENT_SECRET: ${{ inputs.environment == 'integration' && secrets.CLIENT_SECRET || secrets.CLIENT_SECRET_PROD}} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Log in with Azure | |
uses: azure/login@v1 | |
with: | |
creds: ${{ inputs.environment == 'integration' && secrets.INTEGRATION_CREDS || secrets.PRODUCTION_CREDS}} | |
- name: run terraform init | |
working-directory: ${{ env.WORK_DIR }} | |
run: terraform init | |
- name: run terraform plan | |
working-directory: ${{ env.WORK_DIR }} | |
run: terraform plan -out=./plan$GITHUB_RUN_ID | |
- name: 'Upload Artifact' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Planning$GITHUB_RUN_ID | |
path: ./plan$GITHUB_RUN_ID | |
retention-days: 1 | |
# - name: terraform apply | |
# working-directory: ${{ env.WORK_DIR }} | |
# run: terraform apply -auto-approve |