Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tfc backend #570

Closed
21 changes: 12 additions & 9 deletions .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ jobs:
terraform:
name: "Terraform"
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
Expand All @@ -35,32 +37,33 @@ jobs:
- name: Terraform Plan
id: plan
if: github.event_name == 'pull_request'
run: terraform plan -no-color
run: terraform plan -no-color -input=false
continue-on-error: true

- uses: actions/[email protected]
- name: Update Pull Request
uses: actions/github-script@v6
if: github.event_name == 'pull_request'
env:
PLAN: "terraform\n${{ steps.plan.outputs.stdout }}"
PLAN: ${{ 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.outputs.stdout }}\`
#### Terraform Validation 🤖\`${{ steps.validate.outcome }}\`
#### Terraform Plan 📖\`${{ steps.plan.outcome }}\`

<details><summary>Show Plan</summary>

\`\`\`\n
\`\`\`terraform\n
${process.env.PLAN}
\`\`\`

</details>

*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`*`;
*Pushed by: @${{ github.actor }}, Action: \`${{ github.event_name }}\`*`;

github.issues.createComment({
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
Expand All @@ -73,4 +76,4 @@ jobs:

- name: Terraform Apply
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
run: terraform apply -auto-approve
run: terraform apply -auto-approve -input=false
6 changes: 3 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ terraform {
required_version = "~> 1.0"

backend "remote" {
organization = "ACG-Terraform-Demos78"
organization = "org-jim1"

workspaces {
name = "demo-github-actions"
name = "workspace-jim1"
}
}
}
Expand All @@ -36,7 +36,7 @@ resource "aws_instance" "web" {

user_data = <<-EOF
#!/bin/bash
echo "Hello, Everyone!" > index.html
echo "Hello, Everyone1!" > index.html
nohup busybox httpd -f -p 8080 &
EOF
}
Expand Down
Loading