chore(deps): update terraform kubectl to 1.18.0 - autoclosed #45
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 CI Pipeline" | |
on: | |
push: | |
paths: | |
- "terraform/**" | |
branches-ignore: [main] | |
pull_request: | |
types: [opened, reopened, closed] | |
branches: | |
- "main" | |
paths: | |
- "terraform/**" | |
release: | |
types: [released] | |
workflow_dispatch: | |
env: | |
TF_CLOUD_ORGANIZATION: "${{ vars.TF_CLOUD_ORGANIZATION }}" | |
TF_API_TOKEN: "${{ secrets.TF_API_TOKEN }}" | |
TF_WORKSPACE: "${{ vars.TF_WORKSPACE }}" | |
TF_WORKING_DIR: "./terraform" | |
PLURALITH_ORG_ID: "${{ vars.PLURALITH_ORG_ID }}" | |
PLURALITH_PROJECT_ID: "${{ vars.PLURALITH_PROJECT_ID }}" | |
permissions: | |
contents: write | |
pull-requests: write | |
defaults: | |
run: | |
working-directory: ./terraform | |
shell: bash | |
jobs: | |
terraform-dev-plan: | |
name: "Terraform Plan (Development)" | |
runs-on: ubuntu-latest | |
environment: dev | |
if: >- | |
github.event_name == 'push' || | |
github.event_name == 'workflow_dispatch' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4 | |
- uses: terraform-linters/setup-tflint@8093687ecc9dcbfa88d07c103ad4176739a7287e # v4 | |
name: Setup TFLint | |
with: | |
tflint_version: latest | |
- name: Show version | |
run: tflint --version | |
- name: Init TFLint | |
run: tflint --init | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
- name: Run TFLint | |
id: lint | |
run: tflint -f compact | |
- name: Setup Terraform | |
id: tfc-setup | |
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3 | |
with: | |
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }} | |
terraform_wrapper: false | |
- name: Terraform fmt | |
id: fmt | |
run: terraform fmt -check | |
- name: Terraform Init | |
id: init | |
run: terraform init -upgrade | |
- name: Terraform Validate | |
id: validate | |
run: terraform validate -no-color | |
- name: tfsec | |
id: security | |
uses: aquasecurity/tfsec-action@b466648d6e39e7c75324f25d83891162a721f2d6 # v1.0.3 | |
with: | |
working_directory: "${{ env.TF_WORKING_DIR }}" | |
# Set up and authenticate Pluralith | |
- name: Pluralith Init | |
# uses: Pluralith/actions/[email protected] | |
uses: Just-Insane/pluralith-actions/init@e5d17b2206d59f65419079e2c51db6b9096ddcfd | |
with: | |
terraform-path: "${{ env.TF_WORKING_DIR }}" | |
api-key: "${{ secrets.PLURALITH_API_KEY }}" | |
org-id: "${{ vars.PLURALITH_ORG_ID }}" | |
project-id: "${{ vars.PLURALITH_PROJECT_ID }}" | |
- name: Pluralith Run Plan | |
id: plan | |
# uses: Pluralith/actions/[email protected] | |
uses: Just-Insane/pluralith-actions/run@e5d17b2206d59f65419079e2c51db6b9096ddcfd | |
with: | |
terraform-command: "plan" | |
terraform-path: "${{ env.TF_WORKING_DIR }}" | |
title: "${{ env.name }}" | |
show-changes: true | |
show-drift: true | |
show-costs: false | |
- name: Pluralith Comment | |
id: comment | |
uses: Just-Insane/pluralith-actions/comment@e5d17b2206d59f65419079e2c51db6b9096ddcfd | |
with: | |
terraform-path: "${{ env.TF_WORKING_DIR }}" | |
target-type: commit | |
- name: truncate terraform plan result | |
run: | | |
plan=$(cat <<'EOF' | |
${{ format('{0}{1}', steps.plan.outputs.stdout, steps.plan.outputs.stderr) }} | |
EOF | |
) | |
echo "PLAN<<EOF" >> $GITHUB_ENV | |
echo "${plan:0:65536}" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
- name: Create commit comment | |
uses: peter-evans/commit-comment@5a6f8285b8f2e8376e41fe1b563db48e6cf78c09 # v3 | |
id: cc | |
# env: | |
# APPLY: "terraform\n${{ steps.apply.outputs.stdout }}" | |
with: | |
body: | | |
#### TLint Format and Style π\`${{ steps.lint.outcome }}\` | |
#### Terraform Format and Style π\`${{ steps.fmt.outcome }}\` | |
#### Terraform Initialization βοΈ\`${{ steps.init.outcome }}\` | |
#### Terraform Validation π€\`${{ steps.validate.outcome }}\` | |
<details><summary>Validation Output</summary> | |
```\n | |
${{ steps.validate.outputs.stdout }} | |
``` | |
</details> | |
#### TFSec Security π€\`${{ steps.security.outcome }}\` | |
#### Terraform Apply π\`${{ steps.plan.outcome }}\` | |
<details><summary>Show Apply</summary> | |
```\n | |
$PLAN | |
``` | |
</details> | |
#### Pluralith Graph | |
<details><summary>Show Graph</summary> | |
${{ steps.comment.outputs.body }} | |
</details> | |
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Working Directory: \`${{ env.TF_WORKING_DIR }}\`, Workflow: \`${{ github.workflow }}\`*`; | |
- name: Check outputs | |
run: | | |
echo "Comment ID - ${{ steps.cc.outputs.comment-id }}" | |
terraform-dev-apply: | |
name: "Terraform Apply (Development)" | |
runs-on: ubuntu-latest | |
environment: dev | |
if: >- | |
github.event_name == 'push' || | |
github.event_name == 'workflow_dispatch' | |
needs: terraform-dev-plan | |
steps: | |
- name: Checkout | |
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4 | |
- uses: terraform-linters/setup-tflint@8093687ecc9dcbfa88d07c103ad4176739a7287e # v4 | |
name: Setup TFLint | |
with: | |
tflint_version: latest | |
- name: Show version | |
run: tflint --version | |
- name: Init TFLint | |
run: tflint --init | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
- name: Run TFLint | |
id: lint | |
run: tflint -f compact | |
- name: Setup Terraform | |
id: tfc-setup | |
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3 | |
with: | |
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }} | |
terraform_wrapper: false | |
- name: Terraform fmt | |
id: fmt | |
run: terraform fmt -check | |
- name: Terraform Init | |
id: init | |
run: terraform init -upgrade | |
- name: Terraform Validate | |
id: validate | |
run: terraform validate -no-color | |
- name: tfsec | |
id: security | |
uses: aquasecurity/tfsec-action@b466648d6e39e7c75324f25d83891162a721f2d6 # v1.0.3 | |
with: | |
working_directory: "${{ env.TF_WORKING_DIR }}" | |
# Set up and authenticate Pluralith | |
- name: Pluralith Init | |
# uses: Pluralith/actions/[email protected] | |
uses: Just-Insane/pluralith-actions/init@e5d17b2206d59f65419079e2c51db6b9096ddcfd | |
with: | |
terraform-path: "${{ env.TF_WORKING_DIR }}" | |
api-key: "${{ secrets.PLURALITH_API_KEY }}" | |
org-id: "${{ vars.PLURALITH_ORG_ID }}" | |
project-id: "${{ vars.PLURALITH_PROJECT_ID }}" | |
- name: Pluralith Run Apply | |
id: apply | |
# uses: Pluralith/actions/[email protected] | |
uses: Just-Insane/pluralith-actions/run@e5d17b2206d59f65419079e2c51db6b9096ddcfd | |
with: | |
terraform-command: "apply" | |
terraform-path: "${{ env.TF_WORKING_DIR }}" | |
title: "${{ env.name }}" | |
show-changes: true | |
show-drift: true | |
show-costs: false | |
- name: Pluralith Comment | |
id: comment | |
uses: Just-Insane/pluralith-actions/comment@e5d17b2206d59f65419079e2c51db6b9096ddcfd | |
with: | |
terraform-path: "${{ env.TF_WORKING_DIR }}" | |
target-type: commit | |
- name: truncate terraform apply result | |
run: | | |
apply=$(cat <<'EOF' | |
${{ format('{0}{1}', steps.apply.outputs.stdout, steps.apply.outputs.stderr) }} | |
EOF | |
) | |
echo "APPLY<<EOF" >> $GITHUB_ENV | |
echo "${apply:0:65536}" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
- name: Create commit comment | |
uses: peter-evans/commit-comment@5a6f8285b8f2e8376e41fe1b563db48e6cf78c09 # v3 | |
id: cc | |
# env: | |
# APPLY: "terraform\n${{ steps.apply.outputs.stdout }}" | |
with: | |
body: | | |
#### TLint Format and Style π\`${{ steps.lint.outcome }}\` | |
#### Terraform Format and Style π\`${{ steps.fmt.outcome }}\` | |
#### Terraform Initialization βοΈ\`${{ steps.init.outcome }}\` | |
#### Terraform Validation π€\`${{ steps.validate.outcome }}\` | |
<details><summary>Validation Output</summary> | |
```\n | |
${{ steps.validate.outputs.stdout }} | |
``` | |
</details> | |
#### TFSec Security π€\`${{ steps.security.outcome }}\` | |
#### Terraform Apply π\`${{ steps.apply.outcome }}\` | |
<details><summary>Show Apply</summary> | |
```\n | |
$APPLY | |
``` | |
</details> | |
#### Pluralith Graph | |
<details><summary>Show Graph</summary> | |
${{ steps.comment.outputs.body }} | |
</details> | |
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Working Directory: \`${{ env.TF_WORKING_DIR }}\`, Workflow: \`${{ github.workflow }}\`*`; | |
- name: Check outputs | |
run: | | |
echo "Comment ID - ${{ steps.cc.outputs.comment-id }}" | |
terraform-stg-plan: | |
name: "Terraform Plan (Staging)" | |
runs-on: ubuntu-latest | |
environment: stg | |
if: >- | |
github.event_name == 'pull_request' && | |
github.event.action == 'opened' || | |
github.event.action == 'reopened' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4 | |
- uses: terraform-linters/setup-tflint@8093687ecc9dcbfa88d07c103ad4176739a7287e # v4 | |
name: Setup TFLint | |
with: | |
tflint_version: latest | |
- name: Show version | |
run: tflint --version | |
- name: Init TFLint | |
run: tflint --init | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
- name: Run TFLint | |
id: lint | |
run: tflint -f compact | |
- name: Setup Terraform | |
id: tfc-setup | |
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3 | |
with: | |
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }} | |
terraform_wrapper: false | |
- name: Terraform fmt | |
id: fmt | |
run: terraform fmt -check | |
- name: Terraform Init | |
id: init | |
run: terraform init -upgrade | |
- name: Terraform Validate | |
id: validate | |
run: terraform validate -no-color | |
- name: tfsec | |
id: security | |
uses: aquasecurity/tfsec-action@b466648d6e39e7c75324f25d83891162a721f2d6 # v1.0.3 | |
with: | |
working_directory: "${{ env.TF_WORKING_DIR }}" | |
# Set up and authenticate Pluralith | |
- name: Pluralith Init | |
# uses: Pluralith/actions/[email protected] | |
uses: Just-Insane/pluralith-actions/init@e5d17b2206d59f65419079e2c51db6b9096ddcfd | |
with: | |
terraform-path: "${{ env.TF_WORKING_DIR }}" | |
api-key: "${{ secrets.PLURALITH_API_KEY }}" | |
org-id: "${{ vars.PLURALITH_ORG_ID }}" | |
project-id: "${{ vars.PLURALITH_PROJECT_ID }}" | |
- name: Pluralith Run Plan | |
id: plan | |
# uses: Pluralith/actions/[email protected] | |
uses: Just-Insane/pluralith-actions/run@e5d17b2206d59f65419079e2c51db6b9096ddcfd | |
with: | |
terraform-command: "plan" | |
terraform-path: "${{ env.TF_WORKING_DIR }}" | |
title: "${{ env.name }}" | |
show-changes: true | |
show-drift: true | |
show-costs: false | |
- name: Pluralith Comment | |
id: comment | |
uses: Just-Insane/pluralith-actions/comment@e5d17b2206d59f65419079e2c51db6b9096ddcfd | |
with: | |
terraform-path: "${{ env.TF_WORKING_DIR }}" | |
target-type: pull-request | |
- name: truncate terraform plan result | |
run: | | |
plan=$(cat <<'EOF' | |
${{ format('{0}{1}', steps.plan.outputs.stdout, steps.plan.outputs.stderr) }} | |
EOF | |
) | |
echo "PLAN<<EOF" >> $GITHUB_ENV | |
echo "${plan:0:65536}" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7 | |
if: github.event.pull_request.merged == true | |
# env: | |
# APPLY: "terraform\n${{ steps.apply.outputs.stdout }}" | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
// 1. Retrieve existing bot comments for the PR | |
const { data: comments } = await github.rest.issues.listComments({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number, | |
}) | |
const botComment = comments.find(comment => { | |
return comment.user.type === 'Bot' && comment.body.includes('Terraform Format and Style') | |
}) | |
// 2. Prepare format of the comment | |
const output = `#### TLint Format and Style π\`${{ steps.lint.outcome }}\` | |
#### Terraform Format and Style π\`${{ steps.fmt.outcome }}\` | |
#### Terraform Initialization βοΈ\`${{ steps.init.outcome }}\` | |
#### Terraform Validation π€\`${{ steps.validate.outcome }}\` | |
<details><summary>Validation Output</summary> | |
\`\`\`\n | |
${{ steps.validate.outputs.stdout }} | |
\`\`\` | |
</details> | |
#### TFSec Security π€\`${{ steps.security.outcome }}\` | |
#### Terraform Apply π\`${{ steps.plan.outcome }}\` | |
<details><summary>Show Apply</summary> | |
\`\`\`\n | |
$PLAN | |
\`\`\` | |
</details> | |
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Working Directory: \`${{ env.TF_WORKING_DIR }}\`, Workflow: \`${{ github.workflow }}\`*`; | |
// 3. If we have a comment, update it, otherwise create a new one | |
if (botComment) { | |
github.rest.issues.updateComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
comment_id: botComment.id, | |
body: output | |
}) | |
} else { | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: output | |
}) | |
} | |
terraform-stg-apply: | |
name: "Terraform Apply (Staging)" | |
runs-on: ubuntu-latest | |
environment: stg | |
if: ${{ github.event_name == 'pull_request' }} | |
needs: terraform-stg-plan | |
steps: | |
- name: Checkout | |
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4 | |
- uses: terraform-linters/setup-tflint@8093687ecc9dcbfa88d07c103ad4176739a7287e # v4 | |
name: Setup TFLint | |
with: | |
tflint_version: latest | |
- name: Show version | |
run: tflint --version | |
- name: Init TFLint | |
run: tflint --init | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
- name: Run TFLint | |
id: lint | |
run: tflint -f compact | |
- name: Setup Terraform | |
id: tfc-setup | |
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3 | |
with: | |
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }} | |
terraform_wrapper: false | |
- name: Terraform fmt | |
id: fmt | |
run: terraform fmt -check | |
- name: Terraform Init | |
id: init | |
run: terraform init -upgrade | |
- name: Terraform Validate | |
run: terraform validate -no-color | |
- name: tfsec | |
id: security | |
uses: aquasecurity/tfsec-action@b466648d6e39e7c75324f25d83891162a721f2d6 # v1.0.3 | |
with: | |
working_directory: "${{ env.TF_WORKING_DIR }}" | |
# Set up and authenticate Pluralith | |
- name: Pluralith Init | |
# uses: Pluralith/actions/[email protected] | |
uses: Just-Insane/pluralith-actions/init@e5d17b2206d59f65419079e2c51db6b9096ddcfd | |
with: | |
terraform-path: "${{ env.TF_WORKING_DIR }}" | |
api-key: "${{ secrets.PLURALITH_API_KEY }}" | |
org-id: "${{ vars.PLURALITH_ORG_ID }}" | |
project-id: "${{ vars.PLURALITH_PROJECT_ID }}" | |
- name: Pluralith Run Apply | |
id: apply | |
# uses: Pluralith/actions/[email protected] | |
uses: Just-Insane/pluralith-actions/run@e5d17b2206d59f65419079e2c51db6b9096ddcfd | |
with: | |
terraform-command: "apply" | |
terraform-path: "${{ env.TF_WORKING_DIR }}" | |
title: "${{ env.name }}" | |
show-changes: true | |
show-drift: true | |
show-costs: false | |
- name: Pluralith Comment | |
id: comment | |
uses: Just-Insane/pluralith-actions/comment@e5d17b2206d59f65419079e2c51db6b9096ddcfd | |
with: | |
terraform-path: "${{ env.TF_WORKING_DIR }}" | |
target-type: pull-request | |
- name: truncate terraform apply result | |
run: | | |
apply=$(cat <<'EOF' | |
${{ format('{0}{1}', steps.apply.outputs.stdout, steps.apply.outputs.stderr) }} | |
EOF | |
) | |
echo "APPLY<<EOF" >> $GITHUB_ENV | |
echo "${apply:0:65536}" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7 | |
if: github.event_name == 'pull_request' | |
# env: | |
# APPLY: "terraform\n${{ steps.apply.outputs.stdout }}" | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
// 1. Retrieve existing bot comments for the PR | |
const { data: comments } = await github.rest.issues.listComments({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number, | |
}) | |
const botComment = comments.find(comment => { | |
return comment.user.type === 'Bot' && comment.body.includes('Terraform Format and Style') | |
}) | |
// 2. Prepare format of the comment | |
const output = `#### TLint Format and Style π\`${{ steps.lint.outcome }}\` | |
#### Terraform Format and Style π\`${{ steps.fmt.outcome }}\` | |
#### Terraform Initialization βοΈ\`${{ steps.init.outcome }}\` | |
#### Terraform Validation π€\`${{ steps.validate.outcome }}\` | |
<details><summary>Validation Output</summary> | |
\`\`\`\n | |
${{ steps.validate.outputs.stdout }} | |
\`\`\` | |
</details> | |
#### TFSec Security π€\`${{ steps.security.outcome }}\` | |
#### Terraform Apply π\`${{ steps.plan.outcome }}\` | |
<details><summary>Show Apply</summary> | |
\`\`\`\n | |
$APPLY | |
\`\`\` | |
</details> | |
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Working Directory: \`${{ env.TF_WORKING_DIR }}\`, Workflow: \`${{ github.workflow }}\`*`; | |
// 3. If we have a comment, update it, otherwise create a new one | |
if (botComment) { | |
github.rest.issues.updateComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
comment_id: botComment.id, | |
body: output | |
}) | |
} else { | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: output | |
}) | |
} | |
terraform-prod-apply: | |
name: "Terraform Apply (Production)" | |
runs-on: ubuntu-latest | |
environment: prod | |
if: ${{ github.event_name == 'release' }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4 | |
- uses: terraform-linters/setup-tflint@8093687ecc9dcbfa88d07c103ad4176739a7287e # v4 | |
name: Setup TFLint | |
with: | |
tflint_version: latest | |
- name: Show version | |
run: tflint --version | |
- name: Init TFLint | |
run: tflint --init | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
- name: Run TFLint | |
id: lint | |
run: tflint -f compact | |
- name: Setup Terraform | |
id: tfc-setup | |
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3 | |
with: | |
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }} | |
terraform_wrapper: false | |
- name: Terraform fmt | |
id: fmt | |
run: terraform fmt -check | |
- name: Terraform Init | |
id: init | |
run: terraform init -upgrade | |
- name: Terraform Validate | |
run: terraform validate -no-color | |
- name: tfsec | |
id: security | |
uses: aquasecurity/tfsec-action@b466648d6e39e7c75324f25d83891162a721f2d6 # v1.0.3 | |
with: | |
working_directory: "${{ env.TF_WORKING_DIR }}" | |
# Set up and authenticate Pluralith | |
- name: Pluralith Init | |
# uses: Pluralith/actions/[email protected] | |
uses: Just-Insane/pluralith-actions/init@e5d17b2206d59f65419079e2c51db6b9096ddcfd | |
with: | |
terraform-path: "${{ env.TF_WORKING_DIR }}" | |
api-key: "${{ secrets.PLURALITH_API_KEY }}" | |
org-id: "${{ vars.PLURALITH_ORG_ID }}" | |
project-id: "${{ vars.PLURALITH_PROJECT_ID }}" | |
- name: Pluralith Run Apply | |
id: apply | |
# uses: Pluralith/actions/[email protected] | |
uses: Just-Insane/pluralith-actions/run@e5d17b2206d59f65419079e2c51db6b9096ddcfd | |
with: | |
terraform-command: "apply" | |
terraform-path: "${{ env.TF_WORKING_DIR }}" | |
title: "${{ env.name }}" | |
show-changes: true | |
show-drift: true | |
show-costs: false |