π Apply Staging #6
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: "π Apply Staging" | |
| on: | |
| push: | |
| branches: | |
| - "develop" | |
| paths: | |
| - "staging/**" | |
| - "template/**" | |
| - ".github/workflows/apply-staging.yml" | |
| workflow_dispatch: | |
| # Stateless runs must never overlap: each one imports existing buckets into | |
| # a fresh throwaway state, so two racing applies would double-create. | |
| concurrency: | |
| group: terraform-staging | |
| cancel-in-progress: false | |
| permissions: | |
| contents: read | |
| env: | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| TF_VAR_cloudflare_account_id: ${{ secrets.TF_VAR_CLOUDFLARE_ACCOUNT_ID }} | |
| TF_IN_AUTOMATION: "true" | |
| # Lets mise query the GitHub releases API without anonymous rate limits | |
| GITHUB_TOKEN: ${{ github.token }} | |
| jobs: | |
| plan: | |
| name: "π Terraform Plan" | |
| runs-on: ubuntu-latest | |
| environment: "Staging Plan" | |
| defaults: | |
| run: | |
| working-directory: "staging" | |
| steps: | |
| - name: "π Checkout" | |
| uses: actions/checkout@v7 | |
| - name: "π Setup mise" | |
| uses: jdx/mise-action@v4 | |
| - name: "π¨ Format Check" | |
| working-directory: "." | |
| run: terraform fmt -check -recursive staging template | |
| - name: "βοΈ Terraform Init" | |
| run: terraform init -input=false | |
| - name: "β Terraform Validate" | |
| run: terraform validate | |
| - name: "π₯ Import Existing Buckets" | |
| working-directory: "." | |
| run: ./scripts/import-resources.sh | |
| - name: "π Terraform Plan" | |
| run: terraform plan -input=false -out=tfplan | |
| - name: "π¦ Upload Plan" | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: tfplan | |
| path: | | |
| staging/tfplan | |
| staging/terraform.tfstate | |
| retention-days: 3 | |
| if-no-files-found: warn | |
| apply: | |
| name: "π Terraform Apply" | |
| needs: plan | |
| if: github.event_name == 'workflow_dispatch' | |
| runs-on: ubuntu-latest | |
| environment: "Staging" | |
| defaults: | |
| run: | |
| working-directory: "staging" | |
| steps: | |
| - name: "π Checkout" | |
| uses: actions/checkout@v7 | |
| - name: "π Setup mise" | |
| uses: jdx/mise-action@v4 | |
| - name: "π¦ Download Plan" | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: tfplan | |
| path: staging | |
| - name: "βοΈ Terraform Init" | |
| run: terraform init -input=false | |
| - name: "π Terraform Apply" | |
| run: terraform apply -input=false tfplan |