Skip to content

Commit

Permalink
[actions] fix publish script
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Nov 17, 2022
1 parent d350a48 commit 069314a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 43 deletions.
40 changes: 38 additions & 2 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,44 @@ jobs:
result-encoding: string
retries: 3
script: |
const script = require('./.github/workflows/publish');
console.log(await script({ github, context, core }));
console.log(process.cwd());
const ref = context.payload.inputs.tag;
console.log(`Checking status checks for ${ref}`);
const { owner, repo } = context.repo;
const { default_branch: branch } = context.payload.repository;
const branchData = github.rest.repos.getBranch({ owner, repo, branch });
const { data: { check_suites: checkSuites } } = await github.rest.checks.listSuitesForRef({ owner, repo, ref });
const pending = checkSuites.filter(({ status }) => status !== 'completed')
if (pending.length > 0) {
core.setFailed(`Some workflows for ${context.payload.inputs.tag} are still in-progress: ${JSON.stringify(pending))`);
}
const result = await Promise.all(
(await branchData).data.protection.required_status_checks.checks.map(({ context: check_name }) => (
github.rest.checks.listForRef({
owner,
repo,
ref,
check_name,
})
)),
);
const checkRuns = result.flatMap(({ data: { check_runs } }) => check_runs);
checkRuns.forEach(({ name, status, conclusion }) => {
if (status !== 'completed' || conclusion !== 'success') {
console.log(`${name} check failed`);
core.setFailed(`Required status check ${name} did not succeed`);
}
console.log(`${name} check passed`);
});
publish:
needs: [check-status]
Expand Down
41 changes: 0 additions & 41 deletions .github/workflows/publish.js

This file was deleted.

0 comments on commit 069314a

Please sign in to comment.