Skip to content

Commit 29622a2

Browse files
committed
feat(comment): ✨ enhance success comment with deployment details
* removed API URL from success message * added deployment timestamp, release, pull request, commit, and workflow run links
1 parent 0600e0a commit 29622a2

3 files changed

Lines changed: 63 additions & 15 deletions

File tree

build/index.js

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32887,7 +32887,6 @@ async function openFailureIssue(githubToken, context, details) {
3288732887
const body = [
3288832888
'The Coswarm deployment API call failed.',
3288932889
'',
32890-
`**API URL:** ${details.apiUrl}`,
3289132890
`**Image:** ${details.image}`,
3289232891
`**Status:** ${details.error.message}`,
3289332892
responseSection,
@@ -32907,12 +32906,37 @@ async function postSuccessComment(githubToken, context, details) {
3290732906
}
3290832907
const octokit = github.getOctokit(githubToken);
3290932908
const { owner, repo } = context.repo;
32910-
const body = [
32911-
`✅ Coswarm deploy succeeded for ${details.image}`,
32912-
'',
32913-
`**API URL:** ${details.apiUrl}`,
32914-
`**Image:** ${details.image}`,
32915-
].join('\n');
32909+
const lines = [
32910+
`✅ Coswarm deploy succeeded for ${details.image}`,
32911+
'',
32912+
`**Image:** ${details.image}`,
32913+
`**Deployed at:** ${new Date().toISOString()}`,
32914+
];
32915+
32916+
if (context.payload && context.payload.release && context.payload.release.tag_name) {
32917+
const tag = context.payload.release.tag_name;
32918+
const relUrl = context.payload.release.html_url;
32919+
lines.push(`**Release:** ${relUrl ? `[${tag}](${relUrl})` : tag}`);
32920+
}
32921+
32922+
if (context.payload && context.payload.pull_request && context.payload.pull_request.number) {
32923+
const pr = context.payload.pull_request;
32924+
const prUrl = pr.html_url;
32925+
lines.push(`**Pull Request:** ${prUrl ? `[#${pr.number}](${prUrl})` : `#${pr.number}`}`);
32926+
}
32927+
32928+
if (context.sha) {
32929+
const shortSha = context.sha.substring(0, 7);
32930+
const commitUrl = `https://github.com/${owner}/${repo}/commit/${context.sha}`;
32931+
lines.push(`**Commit:** [${shortSha}](${commitUrl})`);
32932+
}
32933+
32934+
if (context.runId) {
32935+
const runUrl = `https://github.com/${owner}/${repo}/actions/runs/${context.runId}`;
32936+
lines.push(`**Workflow run:** ${context.runNumber ? `[#${context.runNumber}](${runUrl})` : `[Run details](${runUrl})`}`);
32937+
}
32938+
32939+
const body = lines.join('\n');
3291632940

3291732941
// If run from a release event, update the release body with a note
3291832942
if (context.payload && context.payload.release && context.payload.release.tag_name) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "coswarm-deploy-action",
3-
"version": "1.0.6",
3+
"version": "1.0.7",
44
"description": "GitHub Action that triggers Coswarm deployments and files issues on failure.",
55
"main": "build/index.js",
66
"scripts": {

src/index.js

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ async function openFailureIssue(githubToken, context, details) {
4949
const body = [
5050
'The Coswarm deployment API call failed.',
5151
'',
52-
`**API URL:** ${details.apiUrl}`,
5352
`**Image:** ${details.image}`,
5453
`**Status:** ${details.error.message}`,
5554
responseSection,
@@ -69,12 +68,37 @@ async function postSuccessComment(githubToken, context, details) {
6968
}
7069
const octokit = github.getOctokit(githubToken);
7170
const { owner, repo } = context.repo;
72-
const body = [
73-
`✅ Coswarm deploy succeeded for ${details.image}`,
74-
'',
75-
`**API URL:** ${details.apiUrl}`,
76-
`**Image:** ${details.image}`,
77-
].join('\n');
71+
const lines = [
72+
`✅ Coswarm deploy succeeded for ${details.image}`,
73+
'',
74+
`**Image:** ${details.image}`,
75+
`**Deployed at:** ${new Date().toISOString()}`,
76+
];
77+
78+
if (context.payload && context.payload.release && context.payload.release.tag_name) {
79+
const tag = context.payload.release.tag_name;
80+
const relUrl = context.payload.release.html_url;
81+
lines.push(`**Release:** ${relUrl ? `[${tag}](${relUrl})` : tag}`);
82+
}
83+
84+
if (context.payload && context.payload.pull_request && context.payload.pull_request.number) {
85+
const pr = context.payload.pull_request;
86+
const prUrl = pr.html_url;
87+
lines.push(`**Pull Request:** ${prUrl ? `[#${pr.number}](${prUrl})` : `#${pr.number}`}`);
88+
}
89+
90+
if (context.sha) {
91+
const shortSha = context.sha.substring(0, 7);
92+
const commitUrl = `https://github.com/${owner}/${repo}/commit/${context.sha}`;
93+
lines.push(`**Commit:** [${shortSha}](${commitUrl})`);
94+
}
95+
96+
if (context.runId) {
97+
const runUrl = `https://github.com/${owner}/${repo}/actions/runs/${context.runId}`;
98+
lines.push(`**Workflow run:** ${context.runNumber ? `[#${context.runNumber}](${runUrl})` : `[Run details](${runUrl})`}`);
99+
}
100+
101+
const body = lines.join('\n');
78102

79103
// If run from a release event, update the release body with a note
80104
if (context.payload && context.payload.release && context.payload.release.tag_name) {

0 commit comments

Comments
 (0)