Skip to content

Commit

Permalink
[FEATURE] Add exclude path option to deploy script
Browse files Browse the repository at this point in the history
Resolves: #3
  • Loading branch information
mai-space authored Apr 5, 2023
1 parent 9a39abd commit b03e182
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ inputs:
description: 'Local path to deploy'
required: false
default: '*'
exclude:
description: 'Paths to exclude from rsync'
required: false
remote:
description: 'Remote destination'
required: false
Expand All @@ -44,7 +47,8 @@ runs:
USER: ${{ inputs.user }}
PASS: ${{ inputs.pass }}
KEY: ${{ inputs.key }}
LOKAL: ${{ inputs.local }}
LOCAL: ${{ inputs.local }}
EXCLUDE: ${{ inputs.exclude }}
REMOTE: ${{ inputs.remote }}
RUNBEFORE: ${{ inputs.runBeforeDeployment }}
RUNAFTER: ${{ inputs.runAfterDeployment }}
16 changes: 14 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ echo "> Starting ${GITHUB_WORKFLOW}:${GITHUB_ACTION}"
# echo "INPUT_PASS: ${INPUT_PASS}"
# echo "INPUT_KEY: ${INPUT_KEY}"
# echo "INPUT_LOCAL: ${INPUT_LOCAL}"
# echo "INPUT_EXCLUDE: ${INPUT_EXCLUDE}"
# echo "INPUT_REMOTE: ${INPUT_REMOTE}"
# echo "INPUT_RUN_BEFORE: ${INPUT_RUNBEFORE}"
# echo "INPUT_RUN_AFTER: ${INPUT_RUNAFTER}"
Expand All @@ -30,7 +31,12 @@ then # Password


echo "> Deploying now"
sshpass -p $INPUT_PASS rsync -avhz --progress --stats -e "ssh -p $INPUT_PORT" $GITHUB_WORKSPACE/$INPUT_LOCAL $INPUT_USER@$INPUT_HOST:$INPUT_REMOTE --delete-during
if [ -z "$INPUT_EXCLUDE" ]
then
sshpass -p $INPUT_PASS rsync -avhz --progress --stats -e "ssh -p $INPUT_PORT" $GITHUB_WORKSPACE/$INPUT_LOCAL $INPUT_USER@$INPUT_HOST:$INPUT_REMOTE --delete-during --exclude=$INPUT_EXCLUDE
else
sshpass -p $INPUT_PASS rsync -avhz --progress --stats -e "ssh -p $INPUT_PORT" $GITHUB_WORKSPACE/$INPUT_LOCAL $INPUT_USER@$INPUT_HOST:$INPUT_REMOTE --delete-during
fi

[[ -z "${INPUT_RUNAFTER}" ]] && {
echo "> Executing commands after deployment"
Expand Down Expand Up @@ -59,7 +65,13 @@ else # Private key
}

echo "> Deploying now"
sshpass -e rsync -avhz --progress --stats -e "ssh -p $INPUT_PORT" $GITHUB_WORKSPACE/$INPUT_LOCAL $INPUT_USER@$INPUT_HOST:$INPUT_REMOTE --delete-during
if [ -z "$INPUT_EXCLUDE" ]
then
sshpass -e rsync -avhz --progress --stats -e "ssh -p $INPUT_PORT" $GITHUB_WORKSPACE/$INPUT_LOCAL $INPUT_USER@$INPUT_HOST:$INPUT_REMOTE --delete-during --exclude=$INPUT_EXCLUDE
else
sshpass -e rsync -avhz --progress --stats -e "ssh -p $INPUT_PORT" $GITHUB_WORKSPACE/$INPUT_LOCAL $INPUT_USER@$INPUT_HOST:$INPUT_REMOTE --delete-during
fi


[[ -z "${INPUT_RUNAFTER}" ]] && {
echo "> Executing commands after deployment"
Expand Down

0 comments on commit b03e182

Please sign in to comment.