fix: redirect for dev.snaps.consensys.net #42
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 Workflow | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- "terraform/**" | |
pull_request: | |
branches: | |
- main | |
paths: | |
- "terraform/**" | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
jobs: | |
terraform: | |
name: 'Terraform' | |
runs-on: ubuntu-latest | |
# Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Get terraform version | |
id: version | |
run: echo "::set-output name=terraform-version::$(cat ./terraform/.tfswitchrc)" | |
- uses: hashicorp/setup-terraform@v1 | |
with: | |
terraform_version: ${{ steps.version.outputs.terraform-version }} | |
- name: Terraform Format | |
id: fmt | |
run: terraform fmt -check -recursive | |
- name: Terraform Init | |
id: init | |
run: terraform init --reconfigure | |
working-directory: "./terraform/live" | |
- name: Terraform Validate | |
id: validate | |
run: terraform validate -no-color | |
working-directory: "./terraform/live" | |
- name: Terraform Plan | |
id: plan | |
if: github.event_name == 'pull_request' | |
run: | | |
terraform plan -input=false -no-color | tee terraform.stdout.txt | |
echo "::set-output name=plan-short::$(grep -e 'Plan: [0-9]* to add, [0-9]* to change, [0-9]* to destroy.' terraform.stdout.txt)" | |
continue-on-error: true | |
working-directory: "./terraform/live" | |
- name: Update Pull Request | |
uses: actions/[email protected] | |
if: github.event_name == 'pull_request' | |
env: | |
PLAN: "terraform\n${{ steps.plan.outputs.plan-short }}" | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const output = `#### Terraform Format and Style 🖌\`${{ steps.fmt.outcome }}\` | |
#### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\` | |
#### Terraform Plan 📖\`${{ steps.plan.outcome }}\` | |
#### Terraform Validation 🤖\`${{ steps.validate.outcome }}\` | |
<details><summary>Show Short Plan</summary> | |
\`\`\`hcl | |
${process.env.PLAN} | |
\`\`\` | |
</details> | |
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`*`; | |
github.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 | |
- name: Terraform Apply | |
if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
run: terraform apply -auto-approve -input=false | |
working-directory: "./terraform/live" |