File tree Expand file tree Collapse file tree 3 files changed +32
-21
lines changed Expand file tree Collapse file tree 3 files changed +32
-21
lines changed Original file line number Diff line number Diff line change @@ -113,8 +113,7 @@ jobs:
113113 - name : Tweak content to publish to existing branch
114114 if : ${{ matrix.branch == 'gh-pages' }}
115115 run : |
116- RANDOM_CHAR=$(echo $RANDOM | tr -dc 'a-zA-Z0-9' | fold -w 1 | head -n 1)
117- echo "<!-- just sayin $RANDOM_CHAR -->" >> integration/index.html
116+ echo "<!-- just sayin -->" >> integration/index.html
118117
119118 - name : Deploy with modifications to existing branch
120119 id : modified
Original file line number Diff line number Diff line change @@ -239,7 +239,7 @@ describe('git', () => {
239239 await deploy ( action )
240240
241241 // Includes the call to generateWorktree
242- expect ( execute ) . toHaveBeenCalledTimes ( 13 )
242+ expect ( execute ) . toHaveBeenCalledTimes ( 14 )
243243 expect ( rmRF ) . toHaveBeenCalledTimes ( 1 )
244244 } )
245245
Original file line number Diff line number Diff line change @@ -100,14 +100,26 @@ export async function generateWorktree(
100100 info (
101101 'Error encountered while checking out branch. Attempting to continue with a new branch name.'
102102 )
103+
103104 branchName = `temp-${ Date . now ( ) } `
104- checkout = new GitCheckout ( branchName )
105105
106- await execute (
107- checkout . toString ( ) ,
108- `${ action . workspace } /${ worktreedir } ` ,
109- action . silent
110- )
106+ try {
107+ checkout = new GitCheckout ( branchName , `origin/${ action . branch } ` )
108+ await execute (
109+ checkout . toString ( ) ,
110+ `${ action . workspace } /${ worktreedir } ` ,
111+ action . silent
112+ )
113+ } catch ( error ) {
114+ info ( 'Unable to track the origin branch…' )
115+
116+ checkout = new GitCheckout ( branchName )
117+ await execute (
118+ checkout . toString ( ) ,
119+ `${ action . workspace } /${ worktreedir } ` ,
120+ action . silent
121+ )
122+ }
111123 }
112124
113125 if ( ! branchExists ) {
@@ -128,19 +140,19 @@ export async function generateWorktree(
128140 action . silent
129141 )
130142 }
143+ }
131144
132- /**
133- * Ensure that the workspace is a safe directory.
134- */
135- try {
136- await execute (
137- `git config --global --add safe.directory "${ action . workspace } /${ worktreedir } "` ,
138- action . workspace ,
139- action . silent
140- )
141- } catch {
142- info ( 'Unable to set worktree temp directory as a safe directory…' )
143- }
145+ /**
146+ * Ensure that the workspace is a safe directory.
147+ */
148+ try {
149+ await execute (
150+ `git config --global --add safe.directory "${ action . workspace } /${ worktreedir } "` ,
151+ action . workspace ,
152+ action . silent
153+ )
154+ } catch {
155+ info ( 'Unable to set worktree temp directory as a safe directory…' )
144156 }
145157 } catch ( error ) {
146158 throw new Error (
You can’t perform that action at this time.
0 commit comments