Skip to content

Commit 3e5c836

Browse files
committed
Update PR comment
1 parent c8cd761 commit 3e5c836

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/action.ts

+13-10
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,6 @@ export class Action {
139139
return token;
140140
}
141141

142-
get prComment(): string {
143-
return `
144-
[${this.commitSha}](https://github.com/${context.repo.owner}/${context.repo.repo}/commit/${this.commitSha}) has been deployed!
145-
- **Commit:** \`${this.commitSha}\`
146-
- **Stage:** \`${this.stage}\`
147-
- **URL:** [${this.httpApiUrl}](${this.httpApiUrl})
148-
`;
149-
}
150-
151142
get commitSha(): string {
152143
if (context.eventName === 'pull_request') {
153144
return `${context.payload.pull_request?.head.sha}`.substring(0, 7);
@@ -165,17 +156,29 @@ export class Action {
165156
async addPrComments(): Promise<void> {
166157
const destroy = boolean(getState('destroy'));
167158
if (destroy) {
159+
debug('Destroying, not adding PR comment.');
168160
return;
169161
}
170162

171163
const { prNumber } = this;
172164
if (!prNumber) {
165+
debug('No PR number found, can not add PR comment.');
166+
return;
167+
}
168+
169+
const httpApiUrl = (await this.httpApiUrl) || 'Unknown';
170+
if (!httpApiUrl) {
171+
debug("No HTTP API URL found, can't add PR comment.");
173172
return;
174173
}
175174

176175
const octokit = getOctokit(this.token);
177176
await octokit.rest.issues.createComment({
178-
body: this.prComment,
177+
body: `
178+
\`${this.commitSha}\` has been deployed!
179+
- **Stage:** \`${this.stage}\`
180+
- **URL:** [${httpApiUrl}](${httpApiUrl})
181+
`,
179182
owner: context.repo.owner,
180183
repo: context.repo.repo,
181184
issue_number: prNumber,

0 commit comments

Comments
 (0)