Add vendor D #125
Workflow file for this run
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 Pull Request Actions" | |
on: | |
pull_request: | |
branches: | |
- main | |
env: | |
APSTRA_URL: "${{ secrets.APSTRA_URL }}" | |
APSTRA_USER: "${{ secrets.APSTRA_USER }}" | |
APSTRA_PASS: "${{ secrets.APSTRA_PASS }}" | |
AWS_ACCESS_KEY_ID: "${{ secrets.AWS_ACCESS_KEY_ID }}" | |
AWS_SECRET_ACCESS_KEY: "${{ secrets.AWS_SECRET_ACCESS_KEY }}" | |
jobs: | |
terraform: | |
name: "Terraform Plan" | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
pull-requests: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Terraform | |
uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 # v2.0.3 | |
with: | |
terraform_version: 1.5.5 | |
- name: Terraform Init | |
run: cd vpn && terraform init | |
- name: Terraform Validate | |
run: cd vpn && terraform validate | |
- id: plan | |
name: Terraform Plan | |
run: cd vpn && terraform plan -no-color | |
- name: Update PR | |
uses: actions/github-script@v6 | |
id: plan-comment | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
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 Plan Output') | |
}); | |
const output = `#### Terraform Plan Output | |
\`\`\` | |
${{ steps.plan.outputs.stdout }} | |
\`\`\` | |
`; | |
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, | |
body: output | |
}); |