Skip to content

Commit

Permalink
Update ci.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
AdmiraalA authored Apr 2, 2024
1 parent 16c5c4f commit 62852a7
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 62852a7

Please sign in to comment.