chore(deps): update dependency ansible-lint to v24.10.0 (#241) #773
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: | |
branches: | |
- main | |
pull_request: | |
defaults: | |
run: | |
working-directory: terraform | |
jobs: | |
lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Terraform | |
uses: hashicorp/setup-terraform@v3 | |
- name: Lint | |
uses: reviewdog/action-tflint@master | |
with: | |
github_token: ${{ github.token }} | |
working_directory: terraform | |
fail_on_error: true | |
filter_mode: nofilter | |
format: | |
name: Format | |
runs-on: ubuntu-latest | |
steps: | |
- name: Generate a token | |
id: token | |
uses: actions/create-github-app-token@v1 | |
with: | |
app-id: ${{ secrets.PUSHER_APP_ID }} | |
private-key: ${{ secrets.PUSHER_PRIVATE_KEY }} | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ steps.token.outputs.token }} | |
- name: Get Terraform Version | |
id: terraform-version | |
uses: bigwheel/[email protected] | |
with: | |
path: ./terraform | |
- name: Setup Terraform | |
uses: hashicorp/setup-terraform@v3 | |
with: | |
terraform_version: ${{ steps.terraform-version.outputs.terraform-version }} | |
- name: Terraform Format | |
id: fmt | |
run: terraform fmt | |
- name: Push | |
id: push | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: "Run terraform format" | |
branch: ${{ github.head_ref }} | |
commit_user_name: ictsc-actions[bot] | |
commit_user_email: 154957684+ictsc-actions[bot]@users.noreply.github.com | |
commit_author: ictsc-actions[bot] <154957684+ictsc-actions[bot]@users.noreply.github.com> | |
- name: Exit with Error If Files Are Changed | |
if: steps.push.outputs.changes_detected == 'true' | |
run: exit 1 | |
plan: | |
name: Plan | |
runs-on: ubuntu-latest | |
env: | |
SAKURACLOUD_ACCESS_TOKEN: ${{ secrets.SAKURACLOUD_ACCESS_TOKEN }} | |
SAKURACLOUD_ACCESS_TOKEN_SECRET: ${{ secrets.SAKURACLOUD_ACCESS_TOKEN_SECRET }} | |
SAKURACLOUD_ZONE: tk1b | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
TF_VAR_cluster_pass: ${{ secrets.TF_VAR_CLUSTER_PASS }} | |
TF_STATE_BUCKET: ictsc-drove | |
TF_WORKSPACE: dev | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Get Terraform Version | |
id: terraform-version | |
uses: bigwheel/[email protected] | |
with: | |
path: ./terraform | |
- name: Setup Terraform | |
uses: hashicorp/setup-terraform@v3 | |
with: | |
terraform_version: ${{ steps.terraform-version.outputs.terraform-version }} | |
- name: Terraform Init | |
id: init | |
run: terraform init -backend-config="bucket=$TF_STATE_BUCKET" | |
- name: Terraform Plan | |
id: plan | |
run: terraform plan -no-color | |
continue-on-error: true | |
- uses: actions/[email protected] | |
if: github.event_name == 'pull_request' | |
env: | |
PLAN: "terraform\n${{ steps.plan.outputs.stdout }}" | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const output = `#### Terraform Initialization \`${{ steps.init.outcome }}\` | |
#### Terraform Plan \`${{ steps.plan.outcome }}\` | |
#### Pusher: ${{ github.actor }}, Action: \`${{ github.event_name }}\` | |
<details><summary>Show Plan</summary> | |
\`\`\`text | |
${process.env.PLAN}\`\`\` | |
</details>` | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: output | |
}) | |
- name: Terraform Plan Status | |
if: steps.plan.outcome == 'failure' | |
run: exit 1 |