Skip to content

Commit

Permalink
Update terraform_plan.yaml (#3)
Browse files Browse the repository at this point in the history
* Update terraform_plan.yaml

* Update terraform_plan.yaml

* Update terraform_plan.yaml

* Update terraform_plan.yaml

* Update terraform_plan.yaml

* Update backend.tf

* Update terraform_plan.yaml

* Update terraform_plan.yaml

* Update terraform_plan.yaml

* Update terraform_plan.yaml

* Update terraform_plan.yaml

* Update terraform_plan.yaml

* Update terraform_plan.yaml

* Update terraform_plan.yaml

* Update terraform_plan.yaml

---------

Co-authored-by: arnol377 <github-actions@census.gov>
  • Loading branch information
arnol377 and arnol377 committed Aug 15, 2024
1 parent 83e0349 commit bef86d9
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 9 deletions.
65 changes: 58 additions & 7 deletions .github/workflows/terraform_plan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ jobs:
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- uses: CSVD/gh-actions-checkout@v3
with:
github-server-url: https://github.e.it.census.gov
ref: ${{ github.head_ref }}
token: ${{ secrets.GH_TOKEN }}


- uses: CSVD/gh-actions-setup-node@v3
Expand All @@ -32,27 +36,74 @@ jobs:

- uses: CSVD/gh-actions-setup-terraform@v2
with:
terraform_wrapper: false
terraform_version: ${{ vars.terraform_version }}

- name: Set output
id: vars
run: echo ::set-output name=short_ref::${GITHUB_REF#refs/*/}

- name: Terraform Format
id: fmt
run: |
terraform fmt -check
terraform fmt
if ! git diff-index --quiet HEAD; then
git config --global user.name '${{ vars.REPO_OWNER }}'
git config --global user.email '${{ vars.REPO_OWNER_EMAIL }}'
git commit -am "Autoformatting TF Code"
git push
echo "auto_format=true" >> $GITHUB_ENV
fi
- name: Autoformat Halt
if: env.auto_format == 'true'
run: exit 1

run: exit 0
- name: Terraform Init
id: init
run: terraform init -upgrade

- name: Terraform Validate
id: validate
run: terraform validate
run: terraform validate -no-color

- name: Terraform Plan
id: plan
run: terraform plan
run: terraform plan -no-color
continue-on-error: true

- uses: CSVD/gh-actions-github-script@v6
if: github.event_name == 'pull_request'
env:
PLAN: "terraform\n${{ steps.plan.outputs.stdout }}"
with:
github-token: ${{ secrets.GH_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 }}\`, Workflow: \`${{ github.workflow }}\`*`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})
4 changes: 2 additions & 2 deletions backend.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
terraform {
backend "s3" {
bucket = "inf-tfstate-229685449397"
key = "csvd-dev-gov/common/apps/terraform-repos"
key = "csvd-dev-gov/common/apps/terraform-repos"
region = "us-gov-east-1"
dynamodb_table = "tf_remote_state"
}
}
}

0 comments on commit bef86d9

Please sign in to comment.