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 for controller v7.1 compatibility #29

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@ jobs:
name: 'Terraform'
# The type of runner that the job will run on
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write

# 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
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
uses: hashicorp/setup-terraform@v2
with:
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}

Expand All @@ -47,13 +50,22 @@ jobs:

# Add terraform plan output back into the pull request
- name: Update Pull Request
uses: actions/github-script@0.9.0
uses: actions/github-script@v6
if: github.event_name == 'pull_request'
env:
PLAN: "terraform\n${{ steps.plan.outputs.stdout }}"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
// 1. Retrieve existing bot comments for the PR
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.find(comment => {
return comment.user.type === 'Bot' && comment.body.includes('Terraform Cloud Plan Output')
});
const output = `#### Terraform Format and Style 🖌\`${{ steps.fmt.outcome }}\`
#### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\`
#### Terraform Plan 📖\`${{ steps.plan.outcome }}\`
Expand All @@ -64,7 +76,14 @@ jobs:
</details>
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`*`;

github.issues.createComment({
if (botComment) {
github.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
});
}
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
Expand Down
2 changes: 1 addition & 1 deletion backend.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = ">= 1.1.0"
required_version = ">= 1.2.0"
backend "remote" {
# organization = "<replace-with-your-Terraform-Cloud-organization-and-uncomment>"
workspaces {
Expand Down
6 changes: 3 additions & 3 deletions versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ terraform {
required_providers {
aviatrix = {
source = "AviatrixSystems/aviatrix"
version = "~> 3.0.1"
version = "~> 3.1.0"
}
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
version = "~> 5.0"
}
}
required_version = ">= 1.0"
required_version = ">= 1.2"
}