refactor: reorganize repo into module-01 remote-state and module-02 c… #7
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-oidc | |
| on: | |
| push: | |
| paths: | |
| - "infra/workload/01-local-state/**" | |
| - ".github/workflows/terraform.yml" | |
| workflow_dispatch: | |
| permissions: | |
| id-token: write | |
| contents: read | |
| env: | |
| TF_WORKING_DIR: infra/workload/01-local-state | |
| ARM_USE_OIDC: "true" | |
| ARM_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }} | |
| ARM_TENANT_ID: ${{ vars.AZURE_TENANT_ID }} | |
| ARM_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }} | |
| jobs: | |
| plan: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: ${{ env.TF_WORKING_DIR }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Azure Login (OIDC) | |
| uses: azure/login@v2 | |
| with: | |
| client-id: ${{ vars.AZURE_CLIENT_ID }} | |
| tenant-id: ${{ vars.AZURE_TENANT_ID }} | |
| subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }} | |
| - name: Setup Terraform | |
| uses: hashicorp/setup-terraform@v3 | |
| with: | |
| terraform_version: 1.6.6 | |
| - name: Terraform fmt (check) | |
| run: terraform fmt -check -recursive | |
| - name: Terraform init | |
| run: terraform init -input=false | |
| - name: Terraform validate | |
| run: terraform validate | |
| - name: Terraform plan | |
| run: terraform plan -no-color -out=tfplan | |
| - name: Upload plan artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: tfplan | |
| path: ${{ env.TF_WORKING_DIR }}/tfplan | |
| apply: | |
| runs-on: ubuntu-latest | |
| needs: plan | |
| if: github.event_name == 'workflow_dispatch' | |
| environment: apply | |
| defaults: | |
| run: | |
| working-directory: ${{ env.TF_WORKING_DIR }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Download plan artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: tfplan | |
| path: ${{ env.TF_WORKING_DIR }} | |
| - name: Azure Login (OIDC) | |
| uses: azure/login@v2 | |
| with: | |
| client-id: ${{ vars.AZURE_CLIENT_ID }} | |
| tenant-id: ${{ vars.AZURE_TENANT_ID }} | |
| subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }} | |
| - name: Setup Terraform | |
| uses: hashicorp/setup-terraform@v3 | |
| with: | |
| terraform_version: 1.6.6 | |
| - name: Terraform init | |
| run: terraform init -input=false | |
| - name: Terraform apply | |
| run: terraform apply -auto-approve tfplan |