Skip to content

Commit

Permalink
chore: update msg
Browse files Browse the repository at this point in the history
  • Loading branch information
hunghg255 committed Dec 21, 2023
1 parent 5adf707 commit 666eabe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/index.js

Large diffs are not rendered by default.

13 changes: 6 additions & 7 deletions src/deploy/pull-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { comment } from '../commentToPullRequest';
import { execSurgeCommand, formatImage, getCommentFooter } from '../helpers';

let failOnErrorGlobal = false;
let fail: (err: Error) => void;
let fail: (err: Error, duration?: number) => void;

export const deployPullRequest = async ({
surgeToken,
Expand Down Expand Up @@ -75,21 +75,18 @@ export const deployPullRequest = async ({
});
};

fail = (err: Error) => {
fail = (err: Error, duration?: number) => {
core.info('error message:');
core.info(JSON.stringify(err, null, 2));
commentIfNotForkedRepo(`
${formatImage({
buildingLogUrl,
gitCommitSha,
buildTime: `${duration || 0}s`,
url: `https://${url}`,
status: '❌ Failed',
})}
😭 Deploy PR Preview ${gitCommitSha} failed. [Build logs](https://github.com/${
github.context.repo.owner
}/${github.context.repo.repo}/actions/runs/${github.context.runId})
${getCommentFooter()}
`);
if (failOnError) {
Expand Down Expand Up @@ -210,6 +207,8 @@ ${formatImage({
${getCommentFooter()}
`);
} catch (error: any) {
fail?.(error);
const duration = (Date.now() - startTime) / 1000;

fail?.(error, duration);
}
};
4 changes: 2 additions & 2 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ export const formatImage = ({
| 🔍 Latest deploy log | ${buildingLogUrl} |
| ⌛ Build time | ${buildTime || '...'} |
| 🚀 Deploy Preview | ${url} |
| 📱 Preview on mobile | <details> <summary>Click me</summary> ![Mobile](${
| 📱 Preview on mobile | <details> <summary>Click me</summary><p><i>Use your smartphone camera to open QR code link.</i></p>![Mobile](${
qrUrl || 'https://avatar.vercel.sh/vercel.svg?text=QR'
}) Use your smartphone camera to open QR code link.</details> |
}) </details> |
`;
};

Expand Down

0 comments on commit 666eabe

Please sign in to comment.