Skip to content

chore(deps): update dependency hashicorp/terraform to v1.10.0 #139

chore(deps): update dependency hashicorp/terraform to v1.10.0

chore(deps): update dependency hashicorp/terraform to v1.10.0 #139

Workflow file for this run

name: Create terraform plan
on:
pull_request:
paths:
- 'terraform/**'
permissions:
contents: read
pull-requests: write
checks: write
jobs:
setup:
runs-on: self-hosted
name: set up directories for terraform
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
outputs:
matrix: ${{ steps.matrix.outputs.value }}
steps:
- id: auth_check
uses: morfien101/actions-authorized-user@v3
with:
username: ${{ github.actor }}
team: "admin"
org: "OctoKode"
whitelist: "myoung34,renovate[bot]"
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: can continue
shell: bash
run: |
if [ ${{ steps.auth_check.outputs.authorized }} != "true" ]; then
echo "::error title=User Unauthorized::User ${{ github.actor }} is not authorized to run this workflow!"
exit 1
fi
- name: Checkout
uses: actions/checkout@v4
- uses: tj-actions/changed-files@v45
id: changed-dirs
with:
dir_names: true
dir_names_exclude_current_dir: true
dir_names_max_depth: 2
- id: matrix
run: |
modified_tf_dirs=$(echo ${{ steps.changed-dirs.outputs.all_changed_and_modified_files }} | sed 's/ /","/g' | sed 's/^/["/g' | sed 's/$/"]/g' | jq '[.[] | select( . | contains("terraform/")) | select( . | contains("talos") | not)]' | tr -d '\n')
echo "value=$modified_tf_dirs" >> "$GITHUB_OUTPUT"
plan:
needs: [ setup ]
runs-on: self-hosted
strategy:
matrix:
dir: ${{fromJSON(needs.setup.outputs.matrix)}}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-1
role-to-assume: ${{ secrets.AWS_ROLE_ARN_TO_ASSUME }}
role-session-name: ${{ secrets.AWS_ROLE_ARN_TO_ASSUME_SESSION_NAME }}
role-skip-session-tagging: true
- uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 # v2.0.3
- name: Terraform fmt
id: fmt
run: terraform fmt -check
continue-on-error: true
working-directory: ${{ matrix.dir }}
- name: Terraform Init
id: init
run: terraform init
working-directory: ${{ matrix.dir }}
- name: Terraform Validate
id: validate
run: terraform validate -no-color
working-directory: ${{ matrix.dir }}
- name: Terraform Plan
id: plan
run: terraform plan -no-color
working-directory: ${{ matrix.dir }}
continue-on-error: true
- uses: actions/github-script@v7
if: github.event_name == 'pull_request'
env:
PLAN: "terraform\n${{ steps.plan.outputs.stdout }}"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const output = `#### 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>
#### Terraform Plan 📖\`${{ steps.plan.outcome }}\`
<details><summary>Show Plan</summary>
\`\`\`\n
${process.env.PLAN}
\`\`\`
</details>
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Working Directory: \`${{ env.tf_actions_working_dir }}\`, Workflow: \`${{ github.workflow }}\`*`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})