File tree 3 files changed +54
-33
lines changed
3 files changed +54
-33
lines changed Original file line number Diff line number Diff line change 67
67
"no-console": 0,
68
68
},
69
69
},
70
+ {
71
+ "files": ".github/workflows/*.js",
72
+ "parserOptions": {
73
+ "ecmaVersion": 2019,
74
+ },
75
+ "rules": {
76
+ "camelcase": 0,
77
+ "no-console": 0,
78
+ "no-restricted-syntax": 0,
79
+ },
80
+ },
70
81
],
71
82
}
Original file line number Diff line number Diff line change 48
48
result-encoding : string
49
49
retries : 3
50
50
script : |
51
- const ref = context.payload.inputs.tag;
52
-
53
- console.log(`Checking status checks for ${ref}`);
54
-
55
- const { owner, repo } = context.repo;
56
- const { default_branch: branch } = context.payload.repository;
57
-
58
- const branch = github.rest.repos.getBranch({ owner, repo, branch });
59
-
60
- const checkSuites = await github.rest.checks.listSuitesForRef({ owner, repo, ref });
61
-
62
- if (checkSuites.some(({ status }) => 'completed')) {
63
- core.setFailed(`Some workflows for ${context.payload.inputs.tag} are still in-progress`);
64
- }
65
-
66
- const { data: { check_runs: checkRuns } } = await Promise.all(
67
- (await branch).data.protection.required_status_checks.checks.map(({ context }) => (
68
- github.rest.checks.listForRef({
69
- owner,
70
- repo,
71
- ref,
72
- check_name: context
73
- })
74
- )
75
- )
76
-
77
- checkRuns.forEach(({ name, status, conclusion }) => {
78
- if (status !== 'completed' || conclusion !== 'success') {
79
- console.log(`${name} check failed`);
80
- core.setFailed(`Required status check ${name} did not succeed`);
81
- }
82
- console.log(`${name} check passed`);
83
- });
51
+ const script = require('./.github/workflows/publish');
52
+ console.log(await script({ github, context, core }));
84
53
85
54
publish :
86
55
needs : [check-status]
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ module . exports = async function publish ( { github, context, core } ) {
4
+ const ref = context . payload . inputs . tag ;
5
+
6
+ console . log ( `Checking status checks for ${ ref } ` ) ;
7
+
8
+ const { owner, repo } = context . repo ;
9
+ const { default_branch : branch } = context . payload . repository ;
10
+
11
+ const branchData = github . rest . repos . getBranch ( { owner, repo, branch } ) ;
12
+
13
+ const { data : { check_suites : checkSuites } } = await github . rest . checks . listSuitesForRef ( { owner, repo, ref } ) ;
14
+
15
+ if ( checkSuites . some ( ( { status } ) => status === 'completed' ) ) {
16
+ core . setFailed ( `Some workflows for ${ context . payload . inputs . tag } are still in-progress` ) ;
17
+ }
18
+
19
+ const result = await Promise . all (
20
+ ( await branchData ) . data . protection . required_status_checks . checks . map ( ( { context : check_name } ) => (
21
+ github . rest . checks . listForRef ( {
22
+ owner,
23
+ repo,
24
+ ref,
25
+ check_name,
26
+ } )
27
+ ) ) ,
28
+ ) ;
29
+
30
+ console . log ( result ) ;
31
+
32
+ const { data : { check_runs : checkRuns } } = result ;
33
+
34
+ checkRuns . forEach ( ( { name, status, conclusion } ) => {
35
+ if ( status !== 'completed' || conclusion !== 'success' ) {
36
+ console . log ( `${ name } check failed` ) ;
37
+ core . setFailed ( `Required status check ${ name } did not succeed` ) ;
38
+ }
39
+ console . log ( `${ name } check passed` ) ;
40
+ } ) ;
41
+ } ;
You can’t perform that action at this time.
0 commit comments