diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index 30ab94417..11a5067ec 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -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 @@ -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/github-script@0.9.0 + - 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 }}\`
Show Plan - \`\`\`\n + \`\`\`terraform\n ${process.env.PLAN} \`\`\`
- *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, @@ -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 diff --git a/main.tf b/main.tf index 284d44867..c13e72467 100644 --- a/main.tf +++ b/main.tf @@ -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" } } } @@ -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 }