-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
19 additions
and
20 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,13 +30,6 @@ jobs: | |
directory: ${{ env.CONFIG_DIRECTORY }} | ||
speculative: true | ||
|
||
- name: Initialize Terraform Backend | ||
run: terraform init -reconfigure | ||
env: | ||
TF_CLOUD_ORGANIZATION: ${{ env.TF_CLOUD_ORGANIZATION }} | ||
TF_API_TOKEN: ${{ secrets.TF_API_TOKEN }} | ||
TF_WORKSPACE: ${{ env.TF_WORKSPACE }} | ||
|
||
- name: Create Plan Run | ||
uses: hashicorp/tfc-workflows-github/actions/[email protected] | ||
id: plan-run | ||
|
@@ -65,23 +58,29 @@ jobs: | |
</details> | ||
*Pushed by: @${{ github.actor }}, Action: \`${{ github.event_name }}\`*`; | ||
if (context.payload.pull_request) { | ||
await github.rest.issues.updateComment({ | ||
comment_id: context.payload.pull_request.issue_url.split('/').pop(), | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
const { owner, repo } = context.repo; | ||
const { number } = context.payload.pull_request || {}; | ||
if (number) { | ||
await github.rest.issues.createComment({ | ||
issue_number: number, | ||
owner, | ||
repo, | ||
body: output | ||
}); | ||
} else { | ||
const response = await github.rest.pulls.create({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
title: 'Automated Pull Request', | ||
head: '${{ github.actor }}:main', | ||
base: 'main', | ||
body: output | ||
console.log('No pull request context found. Creating a new pull request...'); | ||
const newPullRequest = await github.rest.pulls.create({ | ||
owner, | ||
repo, | ||
title: 'Your pull request title here', | ||
head: 'main', // Replace with the name of your branch | ||
base: 'main', // Replace with the name of the base branch | ||
body: 'Your pull request description here' | ||
}); | ||
console.log('Pull request created:', response.data.html_url); | ||
console.log('New pull request created:', newPullRequest.data); | ||
} | ||
- name: Terraform Plan Status | ||
|