Summary #4
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: master-environments | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- master | |
jobs: | |
plan: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: hashicorp/setup-terraform@v3 | |
with: | |
terraform_version: 1.9.5 | |
terraform_wrapper: false | |
- run: echo -n "$CREDENTIALS" > credentials.json | |
env: | |
CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} | |
- run: terraform fmt -check | |
continue-on-error: true | |
- run: terraform init | |
env: | |
GOOGLE_APPLICATION_CREDENTIALS: credentials.json | |
- run: terraform validate -no-color | tee validation | |
- run: terraform plan -out=out.tfplan -no-color -input=false | |
continue-on-error: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.TERRAFORM_GITHUB_TOKEN }} | |
GOOGLE_APPLICATION_CREDENTIALS: credentials.json | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: out.tfplan | |
path: out.tfplan | |
- run: | | |
TMP_OUTPUT=$(terraform show -no-color out.tfplan) | |
FORMATTED_OUTPUT="${TMP_OUTPUT:0:65536}" | |
echo "$FORMATTED_OUTPUT" | tee output | |
- id: output | |
run: | | |
{ | |
echo 'PLAN_OUTPUT<<EOF' | |
echo '```' | |
sed '1d' output | |
echo '```' | |
echo EOF | |
} >> "$GITHUB_STEP_SUMMARY" | |
apply: | |
needs: plan | |
environment: production | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: hashicorp/setup-terraform@v3 | |
with: | |
terraform_version: 1.9.5 | |
terraform_wrapper: false | |
- run: echo -n "$CREDENTIALS" > credentials.json | |
env: | |
CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} | |
- id: init | |
run: terraform init | |
env: | |
GOOGLE_APPLICATION_CREDENTIALS: credentials.json | |
- uses: actions/download-artifact@v4 | |
with: | |
name: out.tfplan | |
- name: Apply | |
run: terraform apply out.tfplan | |
env: | |
GITHUB_TOKEN: ${{ secrets.TERRAFORM_GITHUB_TOKEN }} | |
GOOGLE_APPLICATION_CREDENTIALS: credentials.json |