1 |
|
2 | (async () => {
|
3 | try {
|
4 | console.log('Posting commit status to GitHub...');
|
5 |
|
6 | const { GITHUB_TOKEN, GITHUB_SHA } = process.env;
|
7 |
|
8 | if (!GITHUB_TOKEN || !GITHUB_SHA) {
|
9 | throw new Error(
|
10 | 'GITHUB_TOKEN and GITHUB_SHA environment variables must be present'
|
11 | );
|
12 | }
|
13 |
|
14 | const { Octokit } = require('@octokit/rest');
|
15 | const octokit = new Octokit({
|
16 | auth: GITHUB_TOKEN,
|
17 | });
|
18 |
|
19 | await octokit.repos.createStatus({
|
20 | owner: 'seek-oss',
|
21 | repo: 'playroom',
|
22 | sha: GITHUB_SHA,
|
23 | state: 'success',
|
24 | context: 'Preview Site',
|
25 | target_url: `https://playroom--${GITHUB_SHA}.surge.sh`,
|
26 | description: 'The preview for this PR has been successfully deployed',
|
27 | });
|
28 |
|
29 | console.log('Successfully posted commit status to GitHub');
|
30 | } catch (err) {
|
31 | console.error(err);
|
32 | process.exit(1);
|
33 | }
|
34 | })();
|