File tree Expand file tree Collapse file tree 3 files changed +13
-17
lines changed Expand file tree Collapse file tree 3 files changed +13
-17
lines changed Original file line number Diff line number Diff line change 22
22
uses : ./.github/actions/setup
23
23
24
24
- name : Clean previously generated branch
25
- run : yarn workspace scripts cleanGeneratedBranch
26
- env :
27
- HEAD_REF : ${{ github.head_ref }}
25
+ run : yarn workspace scripts cleanGeneratedBranch ${{ github.head_ref }}
Original file line number Diff line number Diff line change 2
2
import { run } from '../../common' ;
3
3
4
4
/**
5
- * Deletes a branch for it's `generated/${headRef}` name on origin.
6
- *
7
- * @param headRef - The name of the branch to search for.
5
+ * Deletes a branch for its `generated/${headRef}` name on origin.
8
6
*/
9
- export async function cleanGeneratedBranch ( headRef ?: string ) : Promise < void > {
10
- if ( ! process . env . HEAD_REF && ! headRef ) {
11
- throw new Error ( 'Unable to run cleanup, HEAD_REF is missing.' ) ;
12
- }
13
-
14
- const generatedCodeBranch = `generated/${ process . env . HEAD_REF || headRef } ` ;
7
+ async function cleanGeneratedBranch ( headRef : string ) : Promise < void > {
8
+ const generatedCodeBranch = `generated/${ headRef } ` ;
15
9
16
10
if ( ! ( await run ( `git ls-remote --heads origin ${ generatedCodeBranch } ` ) ) ) {
17
11
console . log ( `No branch named '${ generatedCodeBranch } ' was found.` ) ;
@@ -26,6 +20,12 @@ export async function cleanGeneratedBranch(headRef?: string): Promise<void> {
26
20
await run ( `git push -d origin ${ generatedCodeBranch } ` ) ;
27
21
}
28
22
29
- if ( process . env . HEAD_REF ) {
30
- cleanGeneratedBranch ( ) ;
23
+ const args = process . argv . slice ( 2 ) ;
24
+
25
+ if ( ! args || args . length === 0 ) {
26
+ throw new Error (
27
+ 'The base branch should be passed as a cli parameter of the `cleanGeneratedBranch` script.'
28
+ ) ;
31
29
}
30
+
31
+ cleanGeneratedBranch ( args [ 0 ] ) ;
Original file line number Diff line number Diff line change @@ -4,8 +4,6 @@ import { Octokit } from '@octokit/rest';
4
4
import { run } from '../../common' ;
5
5
import { configureGitHubAuthor , OWNER , REPO } from '../../release/common' ;
6
6
7
- import { cleanGeneratedBranch } from './cleanGeneratedBranch' ;
8
-
9
7
if ( ! process . env . GITHUB_TOKEN ) {
10
8
throw new Error ( 'Environment variable `GITHUB_TOKEN` does not exist.' ) ;
11
9
}
@@ -103,7 +101,7 @@ async function pushGeneratedCode(): Promise<void> {
103
101
return ;
104
102
}
105
103
106
- await cleanGeneratedBranch ( baseBranch ) ;
104
+ await run ( `yarn workspace scripts cleanGeneratedBranch ${ baseBranch } ` ) ;
107
105
108
106
const baseCommit = await run ( `git show ${ baseBranch } -s --format=%H` ) ;
109
107
console . log (
You can’t perform that action at this time.
0 commit comments