File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 1+ 'use strict'
2+
3+ // Example to rerun the Serverless workflow 30 times on the current branch:
4+ // GITHUB_TOKEN=$(ddtool auth github token) WORKFLOW=Serverless node scripts/rerun
5+
6+ const { execSync } = require ( 'child_process' )
7+
8+ const {
9+ ATTEMPTS = 30 ,
10+ BRANCH ,
11+ INTERVAL = 600 ,
12+ WORKFLOW
13+ } = process . env
14+
15+ function rerun ( current = 1 ) {
16+ const branch = BRANCH || execSync ( 'git rev-parse --abbrev-ref HEAD' ) . toString ( ) . trim ( )
17+ const result = execSync ( `gh run ls -b ${ branch } -w ${ WORKFLOW } ` ) . toString ( )
18+ const id = result . match ( / \d { 11 } / ) [ 0 ]
19+
20+ execSync ( `gh run rerun ${ id } --repo DataDog/dd-trace-js || exit 0` )
21+
22+ if ( current >= ATTEMPTS ) return
23+
24+ setTimeout ( ( ) => rerun ( current + 1 ) , INTERVAL * 1000 )
25+ }
26+
27+ rerun ( )
You can’t perform that action at this time.
0 commit comments