Skip to content

Commit ef5e465

Browse files
authored
Merge pull request #2 from aosus/upload-directory
Add option to upload Docker directory
2 parents 66f5218 + a03a3ee commit ef5e465

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,15 @@ SSH key must be in PEM format (begins with -----BEGIN RSA PRIVATE KEY-----)
5555

5656
The SSH port to be used. Default is 22.
5757

58-
### `stack_file_name`
58+
### `compose_file_path`
5959

60-
Docker stack file used. Default is docker-compose.yml
60+
path for Docker compose file used. Default is `docker-compose.yml`(repo root), for example when it's inside a sub-directory `caddy/docker-compose.yml`
61+
62+
### `upload_directory`
63+
Uploads docker compose directory, useful when extra files like Configs are needed for the compose project.
64+
65+
### `docker_compose_directory`
66+
Specifies which directory in the repository to upload, needed for upload_directory
6167

6268
### `docker_login_user`
6369

action.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,18 @@ inputs:
1515
args:
1616
description: Deployment command args.
1717
required: true
18-
compose_file_name:
19-
description: Docker compose file used. Default is docker-compose.yaml
18+
compose_file_path:
19+
description: path for Docker compose file used. Default is is repo root(docker-compose.yml)
2020
required: false
2121
ssh_port:
2222
description: The ssh port of the server. Default is 22
2323
required: false
24+
upload_directory:
25+
description: when enabled, uploads entire docker directory, useful for configuration files needed along the container
26+
default: 'false'
27+
docker_compose_directory:
28+
description: specifies which directory to upload, needed for upload_directory
29+
required: false
2430
docker_login_password:
2531
description: The docker login password
2632
required: false

docker-entrypoint.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ if [ -z "$INPUT_ARGS" ]; then
3535
exit 1
3636
fi
3737

38-
if [ -z "$INPUT_COMPOSE_FILE_NAME" ]; then
39-
INPUT_COMPOSE_FILE_NAME=docker-compose.yml
38+
if [ -z "$INPUT_COMPOSE_FILE_PATH" ]; then
39+
INPUT_COMPOSE_FILE_PATH=docker-compose.yml
4040
fi
4141

4242
if [ -z "$INPUT_SSH_PORT" ]; then
4343
INPUT_SSH_PORT=22
4444
fi
4545

46-
COMPOSE_FILE=${INPUT_COMPOSE_FILE_NAME}
46+
COMPOSE_FILE=${INPUT_COMPOSE_FILE_PATH}
4747
DOCKER_HOST=ssh://${INPUT_REMOTE_DOCKER_HOST}:${INPUT_SSH_PORT}
4848
DEPLOYMENT_COMMAND="docker compose -f $COMPOSE_FILE"
4949

@@ -77,6 +77,17 @@ echo "Create docker context"
7777
docker context create staging --docker "host=ssh://$INPUT_REMOTE_DOCKER_HOST:$INPUT_SSH_PORT"
7878
docker context use staging
7979

80+
if $INPUT_UPLOAD_DIRECTORY
81+
then
82+
echo "upload_directory enabled"
83+
if [ -z "$INPUT_DOCKER_COMPOSE_DIRECTORY" ];
84+
then
85+
echo "Input docker_compose_directory is required when upload_directory is enabled!"
86+
exit 1
87+
fi
88+
tar cjvf - -C "$GITHUB_WORKSPACE" "$INPUT_DOCKER_COMPOSE_DIRECTORY" | ssh -o StrictHostKeyChecking=no "$INPUT_REMOTE_DOCKER_HOST" 'tar -xjvf -'
89+
echo "Upload finished"
90+
fi
8091

8192
if [ -n "$INPUT_DOCKER_LOGIN_PASSWORD" ] || [ -n "$INPUT_DOCKER_LOGIN_USER" ] || [ -n "$INPUT_DOCKER_LOGIN_REGISTRY" ]; then
8293
echo "Connecting to $INPUT_REMOTE_DOCKER_HOST... Command: docker login"

0 commit comments

Comments
 (0)