Collapse service names #20
Workflow file for this run
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 Plan | |
on: | |
pull_request: | |
branches: | |
- main | |
env: | |
TF_VAR_project: ${{ secrets.GCLOUD_PROJECT }} | |
jobs: | |
terraform: | |
name: Run Terraform Plan | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: read | |
pull-requests: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install Terraform | |
uses: hashicorp/setup-terraform@v2 | |
with: | |
terraform_version: 1.5.7 | |
- name: lint | |
run: terraform fmt *.tf modules/*/*.tf | |
shell: bash | |
- name: Set up Cloud SDK | |
uses: google-github-actions/setup-gcloud@v1 | |
with: | |
version: 'latest' | |
- name: Authenticate to Google Cloud | |
id: 'auth' | |
uses: google-github-actions/auth@v1 | |
with: | |
workload_identity_provider: ${{ secrets.GCLOUD_OIDC_POOL }} | |
service_account: ${{ secrets.GSA }} | |
token_format: 'access_token' | |
- name: Configure gcloud | |
run: | | |
gcloud config set project ${{ secrets.GCLOUD_PROJECT }} | |
gcloud config set disable_prompts true | |
- uses: 'docker/login-action@v3' | |
name: 'Docker login' | |
with: | |
registry: 'us-docker.pkg.dev' | |
username: 'oauth2accesstoken' | |
password: '${{ steps.auth.outputs.access_token }}' | |
- name: Terraform Init | |
run: terraform init -upgrade | |
- name: Terraform Plan | |
id: plan | |
run: terraform plan > plan.log | |
continue-on-error: true | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: terraform-plan | |
path: plan.log | |
- name: Post comment with artifact link | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const artifactUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; | |
const commentBody = `:rocket: Terraform plan has been created! [Download Artifact](${artifactUrl})`; | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: commentBody | |
}); |