Commit 389b85f 1 parent 12622a2 commit 389b85f Copy full SHA for 389b85f
File tree 2 files changed +23
-2
lines changed
2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,8 @@ import {generateWorktree} from './worktree'
12
12
import {
13
13
extractErrorMessage ,
14
14
isNullOrUndefined ,
15
- suppressSensitiveInformation
15
+ suppressSensitiveInformation ,
16
+ getRsyncVersion
16
17
} from './util'
17
18
18
19
/**
@@ -110,6 +111,8 @@ export async function deploy(action: ActionInterface): Promise<Status> {
110
111
const temporaryDeploymentBranch = `github-pages-deploy-action/${ Math . random ( )
111
112
. toString ( 36 )
112
113
. substr ( 2 , 9 ) } `
114
+ const rsyncVersion = getRsyncVersion ( )
115
+ const isMkpathSupported = rsyncVersion >= '3.2.3'
113
116
114
117
info ( 'Starting to commit changes…' )
115
118
@@ -166,7 +169,7 @@ export async function deploy(action: ActionInterface): Promise<Status> {
166
169
Allows the user to specify the root if '.' is provided.
167
170
rsync is used to prevent file duplication. */
168
171
await execute (
169
- `rsync -q -av --checksum --progress ${ action . targetFolder ? '--mkpath' : '' } ${ action . folderPath } /. ${
172
+ `rsync -q -av --checksum --progress ${ isMkpathSupported && action . targetFolder ? '--mkpath' : '' } ${ action . folderPath } /. ${
170
173
action . targetFolder
171
174
? `${ temporaryDeploymentDirectory } /${ action . targetFolder } `
172
175
: temporaryDeploymentDirectory
Original file line number Diff line number Diff line change 1
1
import { isDebug , warning } from '@actions/core'
2
+ import { execSync } from 'child_process'
2
3
import { existsSync } from 'fs'
3
4
import path from 'path'
4
5
import {
@@ -140,3 +141,20 @@ export const extractErrorMessage = (error: unknown): string =>
140
141
*/
141
142
export const stripProtocolFromUrl = ( url : string ) : string =>
142
143
url . replace ( / ^ (?: h t t p s ? : \/ \/ ) ? (?: w w w \. ) ? / i, '' ) . split ( '/' ) [ 0 ]
144
+
145
+ /**
146
+ * Gets the rsync version.
147
+ */
148
+ export function getRsyncVersion ( ) : string {
149
+ try {
150
+ const versionOutput = execSync ( 'rsync --version' ) . toString ( )
151
+ const versionMatch = versionOutput . match (
152
+ / r s y n c \s + v e r s i o n \s + ( \d + \. \d + \. \d + ) /
153
+ )
154
+ return versionMatch ? versionMatch [ 1 ] : ''
155
+ } catch ( error ) {
156
+ console . error ( error )
157
+
158
+ return ''
159
+ }
160
+ }
You can’t perform that action at this time.
0 commit comments