Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
caiocsgomes committed Apr 25, 2024
2 parents 90c45c6 + 6385dd3 commit 9d9b92a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
36 changes: 28 additions & 8 deletions .github/workflows/terraform-plan.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Terraform Deploy
name: Terraform Plan

on:
pull_request:
Expand All @@ -7,12 +7,10 @@ on:
- .github/workflows/terraform-plan.yaml


permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
permissions: write-all

jobs:
plan-and-approve:
plan:
runs-on: ubuntu-latest
steps:
- name: configure aws credentials
Expand All @@ -31,16 +29,38 @@ jobs:
run: terraform init
working-directory: terraform/environments/prod
- name: terraform plan
run: echo "::set-output name=plan::$(terraform plan)"
run: |
terraform plan -out=plan.tmp
terraform show -no-color plan.tmp > ${GITHUB_WORKSPACE}/plan.out
working-directory: terraform/environments/prod
id: terraform-plan
- name: update PR with plan
uses: actions/github-script@v7
with:
script: |
github.issues.createComment({
const run_url = process.env.GITHUB_SERVER_URL + '/' + process.env.GITHUB_REPOSITORY + '/actions/runs/' + process.env.GITHUB_RUN_ID
const run_link = '<a href="' + run_url + '">here</a>'
const fs = require('fs')
const plan_file = fs.readFileSync('plan.out', 'utf8')
const plan = plan_file.length > 65000 ? plan_file.toString().substring(0, 65000) + " ..." : plan_file
const truncated_message = plan_file.length > 65000 ? "Output is too long and was truncated. Full output can be found " + run_link + "<br><br>" : ""
const output = `### Terraform plan
<details><summary>Click to see the plan</summary>
\`\`\`diff
${plan}
\`\`\`
</details>
${truncated_message}`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '```' + '${{ steps.terraform-plan.outputs.plan }}' + '```'
body: output
})
2 changes: 1 addition & 1 deletion terraform/environments/prod/eks.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
locals {
name = "ex-${replace(basename(path.cwd), "_", "-")}"
cluster_version = "1.27"
cluster_version = "1.28"
region = var.region

vpc_cidr = var.vpc_cidr
Expand Down

0 comments on commit 9d9b92a

Please sign in to comment.