CCAP-137: Add OpenTofu backend for staging #1
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: Pull request checks | ||
on: | ||
pull_request: | ||
jobs: | ||
plan: | ||
uses: ./.github/workflows/plan.yaml | ||
Check failure on line 8 in .github/workflows/pull-request.yaml GitHub Actions / Pull request checksInvalid workflow file
|
||
with: | ||
# TODO: Get the environments to plan on from the diff. | ||
environment: staging | ||
secrets: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
comment: | ||
runs-on: ubuntu-latest | ||
needs: plan | ||
steps: | ||
- uses: actions/github-script@v7 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
// Retrieve existing bot comments for the pull request. | ||
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('## Plan output') | ||
}) | ||
// Prepare the format of the comment. | ||
const output = `## Plan output\n\n\`\`\`\n${{ needs.plan.outputs.plan }}\n\`\`\`` | ||
// If we have a comment, update it. Otherwise, create a new one. | ||
if (botComment) { | ||
github.rest.issues.updateComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
comment_id: botComment.id, | ||
body: output | ||
}) | ||
} else { | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: output | ||
}) | ||
} |