File tree Expand file tree Collapse file tree 5 files changed +44
-0
lines changed
docs/nx-ghpages/Executors
packages/nx-ghpages/src/executors/deploy Expand file tree Collapse file tree 5 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -21,3 +21,15 @@ Deploy a page to a specified repository's gh-pages branch.
2121### commitMessage
2222
2323- (string): Message of the git commit to gh-pages branch
24+
25+ ### baseBranch
26+
27+ - (string): Base branch to sync the gh-pages branch with
28+
29+ ### syncWithBaseBranch
30+
31+ - (string): Indicate if the gh-pages branch should be synced with the base branch
32+
33+ ### syncStrategy
34+
35+ - (string): Git command to use to sync the gh-pages branch with the base branch
Original file line number Diff line number Diff line change @@ -22,6 +22,9 @@ const options: BuildExecutorSchema = {
2222 remote : '' ,
2323 remoteName : '' ,
2424 commitMessage : '' ,
25+ baseBranch : '' ,
26+ syncWithBaseBranch : false ,
27+ syncStrategy : 'rebase' ,
2528} ;
2629
2730describe ( 'Build Executor' , ( ) => {
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { join } from 'path';
66import { promisify } from 'util' ;
77
88import { BuildExecutorSchema } from './schema' ;
9+ import { readNxJson } from 'nx/src/config/nx-json' ;
910
1011const exec = promisify ( execCallback ) ;
1112
@@ -60,6 +61,15 @@ export default async function deployExecutor(options: BuildExecutorSchema) {
6061 logger . warn ( 'Resetting gh-pages branch, as it already exists.' ) ;
6162 await exec ( `git checkout -B gh-pages` , { cwd : directory } ) ;
6263 }
64+ if ( options . syncWithBaseBranch ) {
65+ const baseBranch =
66+ options . baseBranch || readNxJson ( ) ?. affected ?. defaultBase || 'master' ;
67+ const syncStrategy = options . syncStrategy ;
68+ await exec ( `git ${ syncStrategy } ${ options . remoteName } /${ baseBranch } ` , {
69+ cwd : directory ,
70+ } ) ;
71+ }
72+
6373 await exec ( `git push -f --set-upstream ${ options . remoteName } gh-pages` , {
6474 cwd : directory ,
6575 } ) ;
Original file line number Diff line number Diff line change @@ -3,4 +3,7 @@ export interface BuildExecutorSchema {
33 directory : string ;
44 remoteName : string ;
55 commitMessage : string ;
6+ baseBranch : string ;
7+ syncWithBaseBranch : boolean ;
8+ syncStrategy : 'rebase' | 'merge' ;
69}
Original file line number Diff line number Diff line change 2222 "type" : " string" ,
2323 "description" : " Message of the git commit to gh-pages branch" ,
2424 "default" : " chore: :rocket: deploy new version to Github Pages"
25+ },
26+ "baseBranch" : {
27+ "type" : " string" ,
28+ "description" : " Base branch to sync the gh-pages branch with" ,
29+ "default" : " master"
30+ },
31+ "syncWithBaseBranch" : {
32+ "type" : " string" ,
33+ "description" : " Indicate if the gh-pages branch should be synced with the base branch" ,
34+ "default" : " false"
35+ },
36+ "syncStrategy" : {
37+ "type" : " string" ,
38+ "description" : " Git command to use to sync the gh-pages branch with the base branch" ,
39+ "enum" : [" rebase" , " merge" ],
40+ "default" : " rebase"
2541 }
2642 },
2743 "required" : [" remote" , " directory" ]
You can’t perform that action at this time.
0 commit comments