[仮][変更] Secert Manager Addonを有効化 #93
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: Plan(Basic mode) | |
on: | |
pull_request: | |
branches: | |
- master | |
jobs: | |
plan: | |
permissions: | |
id-token: write | |
pull-requests: write | |
name: Plan | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
dir: [ | |
terraform/basic | |
] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Check diff | |
id: diff | |
uses: technote-space/get-diff-action@v5.0.2 | |
with: | |
PATTERNS: | | |
${{ matrix.dir }}/**/*.tf | |
- name: Authenticate to GCP | |
if: env. GIT_DIFF_FILTERED | |
id: gcp_auth | |
uses: google-github-actions/auth@v1.0.0 | |
with: | |
create_credentials_file: 'true' | |
workload_identity_provider: projects/233207969476/locations/global/workloadIdentityPools/github-action/providers/github-action-provider | |
service_account: ga-planner@mitou-jr.iam.gserviceaccount.com | |
access_token_lifetime: 1200s | |
- name: gcloud auth login by workload identity | |
if: env. GIT_DIFF_FILTERED | |
run: |- | |
gcloud auth login --brief --cred-file="${{ steps.gcp_auth.outputs.credentials_file_path }}" | |
- name: Setup terraform | |
if: env. GIT_DIFF_FILTERED | |
uses: hashicorp/setup-terraform@v1.3.2 | |
with: | |
terraform_version: 1.0.11 | |
- name: Check format | |
id: fmt | |
if: env. GIT_DIFF_FILTERED | |
run: terraform fmt -check -recursive | |
working-directory: ${{ matrix.dir }} | |
- name: Initialize | |
id: init | |
if: env. GIT_DIFF_FILTERED | |
run: terraform init | |
working-directory: ${{ matrix.dir }} | |
- name: Download modules | |
if: env. GIT_DIFF_FILTERED | |
run: terraform get | |
working-directory: ${{ matrix.dir }} | |
- name: Validate | |
if: env. GIT_DIFF_FILTERED | |
run: terraform validate -no-color | |
working-directory: ${{ matrix.dir }} | |
- name: Plan | |
if: env. GIT_DIFF_FILTERED | |
id: plan | |
run: terraform plan -no-color | |
working-directory: ${{ matrix.dir }} | |
continue-on-error: true | |
- name: Comment | |
if: env. GIT_DIFF_FILTERED | |
uses: actions/github-script@v5.0.0 | |
env: | |
PLAN: "terraform\n${{ steps.plan.outputs.stdout }}" | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const output = `## \`${{ matrix.dir }}\` | |
#### Terraform Format and Style 🖌\`${{ steps.fmt.outcome }}\` | |
#### Terraform Plan 📖\`${{ steps.plan.outcome }}\` | |
<details><summary>Show Plan</summary> | |
\`\`\`${process.env.PLAN}\`\`\` | |
</details>`; | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: output | |
}) |