Skip to content

Commit 675a0b7

Browse files
author
Greg Bowler
committed
wip: set owner of deployed directory
1 parent cb4828d commit 675a0b7

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ inputs:
2525
required: true
2626
default: "/app"
2727

28+
path_owner:
29+
description: The user and group to change ownership of deployment path to after transfer
30+
required: false
31+
default: "."
32+
2833
transfer_path:
2934
description: Absolute path on the remote server to use for the transfer, which will contain a directory named as the current Git SHA
3035
required: true
@@ -51,6 +56,7 @@ runs:
5156
ACTION_USER: ${{ inputs.user }}
5257
ACTION_PATH: ${{ inputs.path }}
5358
ACTION_TRANSFER_PATH: ${{ inputs.transfer_path }}
59+
ACTION_PATH_OWNER: ${{ inputs.path_owner }}
5460
ACTION_POST_TRANSFER_SCRIPT: ${{ inputs.post_transfer_script }}
5561
ACTION_POST_TRANSFER_SCRIPT_PREFIX: ${{ inputs.post_transfer_script_prefix }}
5662
id: deploy_run

deploy-action.bash

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ action_dir="$(dirname -- "${BASH_SOURCE[0]}")"
1919
echo "#!/bin/bash"; \
2020
declare -p \
2121
ACTION_PATH \
22+
ACTION_PATH_OWNER \
2223
GITHUB_REF_NAME \
2324
full_transfer_path \
2425
; \

remote-post-transfer.bash

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,23 @@ destination_dir_prev="$destination_dir.previous"
55

66
echo "Started post-transfer script with source ($source_dir) destination ($destination_dir)"
77

8+
if [[ ! -d "$ACTION_PATH" ]]
9+
then
10+
mkdir -p "$ACTION_PATH"
11+
fi
12+
813
if [[ -d "$destination_dir" ]]
914
then
1015
if [[ -d "$destination_dir_prev" ]]
1116
then
12-
echo rm -rf "$destination_dir_prev"
17+
rm -rf "$destination_dir_prev"
1318
fi
1419

15-
echo mv "$destination_dir" "$destination_dir_prev"
20+
mv "$destination_dir" "$destination_dir_prev"
1621
fi
1722

18-
echo mv "$source_dir" "$destination_dir"
23+
mv "$source_dir" "$destination_dir"
24+
chown -R "$ACTION_PATH_OWNER" "$destination_dir"
1925

2026
echo "Completed post-transfer script"
2127

0 commit comments

Comments
 (0)