Skip to content

Commit 1ebbec6

Browse files
chore(release): 1.11.0 [skip ci]
# [1.11.0](v1.10.1...v1.11.0) (2025-06-16) ### Features * allow workflow calls as triggers ([#89](#89)) ([bd5d6aa](bd5d6aa))
1 parent bd5d6aa commit 1ebbec6

File tree

3 files changed

+48
-20
lines changed

3 files changed

+48
-20
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# [1.11.0](https://github.com/liatrio/terraform-change-pr-commenter/compare/v1.10.1...v1.11.0) (2025-06-16)
2+
3+
4+
### Features
5+
6+
* allow workflow calls as triggers ([#89](https://github.com/liatrio/terraform-change-pr-commenter/issues/89)) ([bd5d6aa](https://github.com/liatrio/terraform-change-pr-commenter/commit/bd5d6aafb8c90a8cc0e3d78c32a0f33fcffa27de))
7+
18
## [1.10.1](https://github.com/liatrio/terraform-change-pr-commenter/compare/v1.10.0...v1.10.1) (2025-05-30)
29

310

dist/index.js

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12831,16 +12831,19 @@ const includeLinkToWorkflow = core.getBooleanInput("include-workflow-link");
1283112831
const includeLinkToJob = core.getBooleanInput("include-job-link");
1283212832
const hidePreviousComments = core.getBooleanInput("hide-previous-comments");
1283312833
const logChangedResources = core.getBooleanInput("log-changed-resources");
12834-
const includeTagOnlyResources = core.getBooleanInput("include-tag-only-resources");
12835-
const includeUnchangedResources = core.getBooleanInput("include-unchanged-resources");
12836-
12834+
const includeTagOnlyResources = core.getBooleanInput(
12835+
"include-tag-only-resources",
12836+
);
12837+
const includeUnchangedResources = core.getBooleanInput(
12838+
"include-unchanged-resources",
12839+
);
1283712840

1283812841
// Get current job name from GitHub environment variable
12839-
const currentJobName = process.env.GITHUB_JOB || '';
12840-
const currentRunnerName = process.env.RUNNER_NAME || '';
12842+
const currentJobName = process.env.GITHUB_JOB || "";
12843+
const currentRunnerName = process.env.RUNNER_NAME || "";
1284112844

1284212845
// Log the job name for debugging
12843-
console.log('Current job name:', currentJobName);
12846+
console.log("Current job name:", currentJobName);
1284412847

1284512848
const workflowLink = includeLinkToWorkflow
1284612849
? `
@@ -12861,13 +12864,15 @@ async function getJobId() {
1286112864
repo: context.repo.repo,
1286212865
run_id: context.runId,
1286312866
});
12864-
12867+
1286512868
// Find the current job by name
12866-
const job = response.data.jobs.find(job =>
12867-
job.runner_name === currentRunnerName &&
12868-
(job.name.endsWith(currentJobName) || job.name.startsWith(currentJobName))
12869+
const job = response.data.jobs.find(
12870+
(job) =>
12871+
job.runner_name === currentRunnerName &&
12872+
(job.name.endsWith(currentJobName) ||
12873+
job.name.startsWith(currentJobName)),
1286912874
);
12870-
12875+
1287112876
if (job) {
1287212877
console.log(`Found job ID: ${job.id} for job name: ${job.name}`);
1287312878
// Create job link with the numeric job ID
@@ -12918,7 +12923,8 @@ const output = () => {
1291812923
let body = "";
1291912924
// for each file
1292012925
for (const file of inputFilenames) {
12921-
const resource_changes = JSON.parse(fs.readFileSync(file)).resource_changes || [];
12926+
const resource_changes =
12927+
JSON.parse(fs.readFileSync(file)).resource_changes || [];
1292212928
try {
1292312929
let changed_resources = resource_changes.filter((resource) => {
1292412930
return resource.change.actions != ["no-op"];
@@ -12988,7 +12994,7 @@ const output = () => {
1298812994
${commentHeader}
1298912995
<details ${expandDetailsComment ? "open" : ""}>
1299012996
<summary>
12991-
<b>Terraform Plan: ${resources_to_create.length} to be created, ${resources_to_delete.length} to be deleted, ${resources_to_update.length} to be updated${includeTagOnlyResources ? `, ${resources_to_tag.length} to be tagged` : ''}, ${resources_to_replace.length} to be replaced, ${resources_unchanged.length} unchanged.</b>
12997+
<b>Terraform Plan: ${resources_to_create.length} to be created, ${resources_to_delete.length} to be deleted, ${resources_to_update.length} to be updated${includeTagOnlyResources ? `, ${resources_to_tag.length} to be tagged` : ""}, ${resources_to_replace.length} to be replaced, ${resources_unchanged.length} unchanged.</b>
1299212998
</summary>
1299312999
${includeUnchangedResources ? details("unchanged", resources_unchanged, "•") : ""}
1299413000
${details("create", resources_to_create, "+")}
@@ -13133,7 +13139,7 @@ async function run() {
1313313139
jobLink = await getJobId();
1313413140
console.log("Job link generated:", jobLink);
1313513141
}
13136-
13142+
1313713143
let rawOutput = output();
1313813144
let createComment = true;
1313913145

@@ -13149,7 +13155,10 @@ async function run() {
1314913155
console.log("includePlanSummary", includePlanSummary);
1315013156
if (includePlanSummary) {
1315113157
core.info("Adding plan output to job summary");
13152-
core.summary.addHeading("Terraform Plan Results").addRaw(rawOutput).write();
13158+
core.summary
13159+
.addHeading("Terraform Plan Results")
13160+
.addRaw(rawOutput)
13161+
.write();
1315313162
}
1315413163

1315513164
console.log("quietMode", quietMode);
@@ -13163,10 +13172,22 @@ async function run() {
1316313172
createComment = false;
1316413173
}
1316513174

13166-
if (context.eventName === "pull_request") {
13167-
core.info(
13168-
`Found PR # ${context.issue.number} from workflow context - proceeding to comment.`,
13169-
);
13175+
if (
13176+
context.eventName === "pull_request" ||
13177+
context.eventName === "workflow_call"
13178+
) {
13179+
// Verify we have PR context available in the case that it's a workflow_call event- should always pass for pull_request
13180+
if (context.issue && context.issue.number) {
13181+
core.info(
13182+
`Found PR # ${context.issue.number} from ${context.eventName} event - proceeding to comment.`,
13183+
);
13184+
} else {
13185+
core.info(
13186+
`${context.eventName} event detected but no PR context available.`,
13187+
);
13188+
core.info("Skipping comment creation.");
13189+
createComment = false;
13190+
}
1317013191
} else {
1317113192
core.info("Action doesn't seem to be running in a PR workflow context.");
1317213193
core.info("Skipping comment creation.");

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "terraform-change-pr-commenter",
3-
"version": "1.10.1",
3+
"version": "1.11.0",
44
"description": "GitHub Action to read changes from Terraform plan JSON, summarize changes, and post them in a GitHub Pull Request Comment",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)