Skip to content

Commit 6217370

Browse files
committed
[actions] fix publish script
1 parent d350a48 commit 6217370

File tree

2 files changed

+36
-43
lines changed

2 files changed

+36
-43
lines changed

.github/workflows/npm-publish.yml

+36-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,42 @@ jobs:
4848
result-encoding: string
4949
retries: 3
5050
script: |
51-
const script = require('./.github/workflows/publish');
52-
console.log(await script({ github, context, core }));
51+
console.log(process.cwd());
52+
const ref = context.payload.inputs.tag;
53+
54+
console.log(`Checking status checks for ${ref}`);
55+
56+
const { owner, repo } = context.repo;
57+
const { default_branch: branch } = context.payload.repository;
58+
59+
const branchData = github.rest.repos.getBranch({ owner, repo, branch });
60+
61+
const { data: { check_suites: checkSuites } } = await github.rest.checks.listSuitesForRef({ owner, repo, ref });
62+
63+
if (checkSuites.some(({ status }) => status === 'completed')) {
64+
core.setFailed(`Some workflows for ${context.payload.inputs.tag} are still in-progress`);
65+
}
66+
67+
const result = await Promise.all(
68+
(await branchData).data.protection.required_status_checks.checks.map(({ context: check_name }) => (
69+
github.rest.checks.listForRef({
70+
owner,
71+
repo,
72+
ref,
73+
check_name,
74+
})
75+
)),
76+
);
77+
78+
const checkRuns = result.flatMap(({ data: { check_runs } }) => check_runs);
79+
80+
checkRuns.forEach(({ name, status, conclusion }) => {
81+
if (status !== 'completed' || conclusion !== 'success') {
82+
console.log(`${name} check failed`);
83+
core.setFailed(`Required status check ${name} did not succeed`);
84+
}
85+
console.log(`${name} check passed`);
86+
});
5387
5488
publish:
5589
needs: [check-status]

.github/workflows/publish.js

-41
This file was deleted.

0 commit comments

Comments
 (0)