|
48 | 48 | result-encoding: string
|
49 | 49 | retries: 3
|
50 | 50 | 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 | + const pending = checkSuites.filter(({ status }) => status !== 'completed') |
| 64 | +
|
| 65 | + if (pending.length > 0) { |
| 66 | + core.setFailed(`Some workflows for ${context.payload.inputs.tag} are still in-progress: ${JSON.stringify(pending))`); |
| 67 | + } |
| 68 | +
|
| 69 | + const result = await Promise.all( |
| 70 | + (await branchData).data.protection.required_status_checks.checks.map(({ context: check_name }) => ( |
| 71 | + github.rest.checks.listForRef({ |
| 72 | + owner, |
| 73 | + repo, |
| 74 | + ref, |
| 75 | + check_name, |
| 76 | + }) |
| 77 | + )), |
| 78 | + ); |
| 79 | +
|
| 80 | + const checkRuns = result.flatMap(({ data: { check_runs } }) => check_runs); |
| 81 | +
|
| 82 | + checkRuns.forEach(({ name, status, conclusion }) => { |
| 83 | + if (status !== 'completed' || conclusion !== 'success') { |
| 84 | + console.log(`${name} check failed`); |
| 85 | + core.setFailed(`Required status check ${name} did not succeed`); |
| 86 | + } |
| 87 | + console.log(`${name} check passed`); |
| 88 | + }); |
53 | 89 |
|
54 | 90 | publish:
|
55 | 91 | needs: [check-status]
|
|
0 commit comments