Skip to content

Commit 21dd06b

Browse files
chore(release): 1.10.0 [skip ci]
# [1.10.0](v1.9.0...v1.10.0) (2025-04-29) ### Features * Add tags tracking, unchanged resources, and matrix support for jobs ([#87](#87)) ([b2f5356](b2f5356))
1 parent b2f5356 commit 21dd06b

File tree

3 files changed

+53
-8
lines changed

3 files changed

+53
-8
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# [1.10.0](https://github.com/liatrio/terraform-change-pr-commenter/compare/v1.9.0...v1.10.0) (2025-04-29)
2+
3+
4+
### Features
5+
6+
* Add tags tracking, unchanged resources, and matrix support for jobs ([#87](https://github.com/liatrio/terraform-change-pr-commenter/issues/87)) ([b2f5356](https://github.com/liatrio/terraform-change-pr-commenter/commit/b2f535616c169467e523e6ff35ba684606ee2521))
7+
18
# [1.9.0](https://github.com/liatrio/terraform-change-pr-commenter/compare/v1.8.0...v1.9.0) (2025-04-24)
29

310

dist/index.js

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12831,9 +12831,13 @@ 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+
1283412837

1283512838
// Get current job name from GitHub environment variable
1283612839
const currentJobName = process.env.GITHUB_JOB || '';
12840+
const currentRunnerName = process.env.RUNNER_NAME || '';
1283712841

1283812842
// Log the job name for debugging
1283912843
console.log('Current job name:', currentJobName);
@@ -12855,20 +12859,24 @@ async function getJobId() {
1285512859
const response = await octokit.rest.actions.listJobsForWorkflowRun({
1285612860
owner: context.repo.owner,
1285712861
repo: context.repo.repo,
12858-
run_id: context.runId
12862+
run_id: context.runId,
1285912863
});
1286012864

1286112865
// Find the current job by name
12862-
const job = response.data.jobs.find(job => job.name === currentJobName);
12866+
const job = response.data.jobs.find(job =>
12867+
job.runner_name === currentRunnerName &&
12868+
(job.name.endsWith(currentJobName) || job.name.startsWith(currentJobName))
12869+
);
1286312870

1286412871
if (job) {
12865-
console.log(`Found job ID: ${job.id} for job name: ${currentJobName}`);
12872+
console.log(`Found job ID: ${job.id} for job name: ${job.name}`);
1286612873
// Create job link with the numeric job ID
1286712874
return `
12868-
[Job: ${currentJobName}](${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}/job/${job.id})
12875+
[Job: ${job.name}](${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}/job/${job.id})
1286912876
`;
1287012877
} else {
1287112878
console.log(`Could not find job with name: ${currentJobName}`);
12879+
console.log(`Jobs: \n${JSON.stringify(response.data.jobs, null, 2)}`);
1287212880
return "";
1287312881
}
1287412882
} catch (error) {
@@ -12924,8 +12932,25 @@ const output = () => {
1292412932
resources_to_update = [],
1292512933
resources_to_delete = [],
1292612934
resources_to_replace = [],
12935+
resources_to_tag = [],
1292712936
resources_unchanged = [];
1292812937

12938+
// Deep comparison function to check if objects are identical after removing tags
12939+
const isTagOnlyChange = (before, after) => {
12940+
if (includeTagOnlyResources == false) {
12941+
return false;
12942+
}
12943+
const beforeCopy = JSON.parse(JSON.stringify(before || {}));
12944+
const afterCopy = JSON.parse(JSON.stringify(after || {}));
12945+
12946+
delete beforeCopy.tags;
12947+
delete beforeCopy.tags_all;
12948+
delete afterCopy.tags;
12949+
delete afterCopy.tags_all;
12950+
12951+
return JSON.stringify(beforeCopy) === JSON.stringify(afterCopy);
12952+
};
12953+
1292912954
// for each resource changes
1293012955
for (const resource of resource_changes) {
1293112956
const change = resource.change;
@@ -12948,7 +12973,11 @@ const output = () => {
1294812973
}
1294912974
break;
1295012975
case "update":
12951-
resources_to_update.push(address);
12976+
if (isTagOnlyChange(change.before, change.after)) {
12977+
resources_to_tag.push(address);
12978+
} else {
12979+
resources_to_update.push(address);
12980+
}
1295212981
break;
1295312982
}
1295412983
}
@@ -12959,11 +12988,13 @@ const output = () => {
1295912988
${commentHeader}
1296012989
<details ${expandDetailsComment ? "open" : ""}>
1296112990
<summary>
12962-
<b>Terraform Plan: ${resources_to_create.length} to be created, ${resources_to_delete.length} to be deleted, ${resources_to_update.length} to be updated, ${resources_to_replace.length} to be replaced, ${resources_unchanged.length} unchanged.</b>
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>
1296312992
</summary>
12993+
${includeUnchangedResources ? details("unchanged", resources_unchanged, "•") : ""}
1296412994
${details("create", resources_to_create, "+")}
1296512995
${details("delete", resources_to_delete, "-")}
1296612996
${details("update", resources_to_update, "!")}
12997+
${includeTagOnlyResources ? details("tag", resources_to_tag, "!") : ""}
1296712998
${details("replace", resources_to_replace, "+")}
1296812999
</details>
1296913000
${commentFooter.map((a) => (a == "" ? "\n" : a)).join("\n")}
@@ -12974,6 +13005,7 @@ ${jobLink}
1297413005
resources_to_create +
1297513006
resources_to_delete +
1297613007
resources_to_update +
13008+
resources_to_tag +
1297713009
resources_to_replace ==
1297813010
[]
1297913011
) {
@@ -12999,11 +13031,17 @@ ${jobLink}
1299913031
};
1300013032

1300113033
const details = (action, resources, operator) => {
13034+
let str_title = "";
1300213035
let str = "";
1300313036

1300413037
if (resources.length !== 0) {
13038+
if (action === "unchanged") {
13039+
str_title = "Unchanged resources";
13040+
} else {
13041+
str_title = `Resources to ${action}`;
13042+
}
1300513043
str = `
13006-
#### Resources to ${action}\n
13044+
#### ${str_title}\n
1300713045
\`\`\`diff\n
1300813046
`;
1300913047
for (const el of resources) {

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.9.0",
3+
"version": "1.10.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)