File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,7 +12,8 @@ import {generateWorktree} from './worktree'
1212import {
1313 extractErrorMessage ,
1414 isNullOrUndefined ,
15- suppressSensitiveInformation
15+ suppressSensitiveInformation ,
16+ getRsyncVersion
1617} from './util'
1718
1819/**
@@ -110,6 +111,8 @@ export async function deploy(action: ActionInterface): Promise<Status> {
110111 const temporaryDeploymentBranch = `github-pages-deploy-action/${ Math . random ( )
111112 . toString ( 36 )
112113 . substr ( 2 , 9 ) } `
114+ const rsyncVersion = getRsyncVersion ( )
115+ const isMkpathSupported = rsyncVersion >= '3.2.3'
113116
114117 info ( 'Starting to commit changes…' )
115118
@@ -166,7 +169,7 @@ export async function deploy(action: ActionInterface): Promise<Status> {
166169 Allows the user to specify the root if '.' is provided.
167170 rsync is used to prevent file duplication. */
168171 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 } /. ${
170173 action . targetFolder
171174 ? `${ temporaryDeploymentDirectory } /${ action . targetFolder } `
172175 : temporaryDeploymentDirectory
Original file line number Diff line number Diff line change 11import { isDebug , warning } from '@actions/core'
2+ import { execSync } from 'child_process'
23import { existsSync } from 'fs'
34import path from 'path'
45import {
@@ -140,3 +141,20 @@ export const extractErrorMessage = (error: unknown): string =>
140141 */
141142export const stripProtocolFromUrl = ( url : string ) : string =>
142143 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