From 891175368a9ba48de79a82d6ed853a8b272a6124 Mon Sep 17 00:00:00 2001 From: Contention Date: Fri, 24 Mar 2023 15:11:50 +0000 Subject: [PATCH 01/11] Updated base image --- Dockerfile | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 93a81de..9ad3b5f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,4 @@ -FROM debian:9.5-slim - - -# Update -RUN apt-get update - - -# Install packages -RUN apt-get -yq install rsync openssh-client +FROM drinternet/rsync:v1.4.3 # Label From b111bee195cd21c13355868b4278273e152072f5 Mon Sep 17 00:00:00 2001 From: Contention Date: Fri, 24 Mar 2023 16:04:25 +0000 Subject: [PATCH 02/11] Updated description --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 9ad3b5f..fb84b6b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM drinternet/rsync:v1.4.3 # Label LABEL "com.github.actions.name"="rsync deployments" -LABEL "com.github.actions.description"="For deploying code to a webserver via rsync over ssh" +LABEL "com.github.actions.description"="Quick and simple method of deploying code to a webserver via rsync over ssh" LABEL "com.github.actions.icon"="truck" LABEL "com.github.actions.color"="yellow" From 862fef3e691ffe51b205b8cb4d80628425dd1867 Mon Sep 17 00:00:00 2001 From: Contention Date: Fri, 24 Mar 2023 16:22:22 +0000 Subject: [PATCH 03/11] Updated to reflect v2 --- README.md | 57 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index aa9a04a..d4999e3 100644 --- a/README.md +++ b/README.md @@ -4,37 +4,54 @@ This GitHub Action deploys *everything* in `GITHUB_WORKSPACE` to a folder on a s This action would usually follow a build/test action which leaves deployable code in `GITHUB_WORKSPACE`. -# Required SECRETs +# Required secrets This action needs a `DEPLOY_KEY` secret variable. This should be the private key part of an ssh key pair. The public key part should be added to the authorized_keys file on the server that receives the deployment. -# Required ARGs +# Required inputs -This action can receive three `ARG`s: +This action requires six inputs: -1. The first is for any initial/required rsync flags, eg: `-avzr --delete` +1. `FLAGS` for any initial/required rsync flags, eg: `-avzr --delete` -2. The second is for any `--exclude` flags and directory pairs, eg: `--exclude .htaccess --exclude /uploads/`. Use "" if none required. +2. `EXCLUDES` for any `--exclude` flags and directory pairs, eg: `--exclude .htaccess --exclude /uploads/`. Use `""` if none required. -3. The third is for the deployment target, and should be in the format: `[USER]@[HOST]:[PATH]` +3. `USER` for the deployment target, and should be in the format: `deploybot` + +4. `HOST` for the server user, eg: `myserver.com` + +5. `LOCALPATH` for the local path to sync, eg: `/src` + +5. `REMOTEPATH` for the remote path to sync, eg: `/srv/myapp/public/htdocs/` # Example usage ``` -workflow "All pushes" { - on = "push" - resolves = ["Deploy to Staging"] -} - -action "Deploy to Staging" { - uses = "contention/action-rsync-deploy@master" - secrets = ["DEPLOY_KEY"] - args = ["-avzr --delete", "--exclude .htaccess --exclude /uploads/", "user@server.com:/srv/myapp/public/htdocs/"] -} -``` +name: Deploy to production + +on: + push: + branches: + - master + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: contention/rsync-deployments@v2.0.0 + with: + FLAGS: -avzr --delete + EXCLUDES: --exclude .htaccess + USER deploybot + HOST: myserver.com + LOCALPATH: /dist + DEST: /srv/myapp/public/htdocs/ + env: + DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }} -## Disclaimer +``` -If you're using GitHub Actions, you'll probably already know that it's still in limited public beta, and GitHub advise against using Actions in production. +## REMINDER! -So, check your keys. Check your deployment paths. And use at your own risk. \ No newline at end of file +Check your keys. Check your deployment paths. Check your flags. And use at your own risk. From a5bf1cc70f6f91d6493127aa5d1601536140e0fa Mon Sep 17 00:00:00 2001 From: Contention Date: Fri, 24 Mar 2023 16:23:11 +0000 Subject: [PATCH 04/11] Tweaked description --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d4999e3..b83b559 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ This action requires six inputs: 4. `HOST` for the server user, eg: `myserver.com` -5. `LOCALPATH` for the local path to sync, eg: `/src` +5. `LOCALPATH` for the local path to sync, eg: `/dist` 5. `REMOTEPATH` for the remote path to sync, eg: `/srv/myapp/public/htdocs/` @@ -42,7 +42,7 @@ jobs: - uses: contention/rsync-deployments@v2.0.0 with: FLAGS: -avzr --delete - EXCLUDES: --exclude .htaccess + EXCLUDES: --exclude .htaccess --exclude /uploads/ USER deploybot HOST: myserver.com LOCALPATH: /dist From a0a657cdc1078dd8d7c6b908eed191b6f956846d Mon Sep 17 00:00:00 2001 From: Contention Date: Fri, 24 Mar 2023 16:23:59 +0000 Subject: [PATCH 05/11] Tweaked description --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b83b559..9400e1f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # rsync deployments -This GitHub Action deploys *everything* in `GITHUB_WORKSPACE` to a folder on a server via rsync over ssh. +This GitHub Action deploys files in `GITHUB_WORKSPACE` to a folder on a server via rsync over ssh. This action would usually follow a build/test action which leaves deployable code in `GITHUB_WORKSPACE`. From e79da04402802bee3b11193bafd99e8491900530 Mon Sep 17 00:00:00 2001 From: Contention Date: Fri, 24 Mar 2023 16:35:32 +0000 Subject: [PATCH 06/11] Updating to V2 --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 45fe097..9ab8325 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -10,4 +10,4 @@ chmod 600 "$SSH_PATH/deploy_key" # Do deployment -sh -c "rsync $1 -e 'ssh -i $SSH_PATH/deploy_key -o StrictHostKeyChecking=no' $2 $GITHUB_WORKSPACE/ $3" +sh -c "rsync $FLAGS -e 'ssh -i $SSH_PATH/deploy_key -o StrictHostKeyChecking=no' $EXCLUDES $GITHUB_WORKSPACE/$LOCALPATH $USER@$HOST:$REMOTEPATH" From 016e24df53888dc18d398536c999707aa1864e13 Mon Sep 17 00:00:00 2001 From: Contention Date: Fri, 24 Mar 2023 18:43:11 +0000 Subject: [PATCH 07/11] Create action.yml --- action.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 action.yml diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..38a9e9a --- /dev/null +++ b/action.yml @@ -0,0 +1,28 @@ +name: 'rsync deployments' +description: 'Quick and simple method of deploying code to a webserver via rsync over ssh' +author: 'Contention' +inputs: + flags: + description: 'Initial/required rsync flags' + required: true + excludes: + description: 'Exclude flags and directory pairs' + required: true + user: + description: 'The server user' + required: true + host: + description: 'The deployment target' + required: true + localpath: + description: 'The local path to sync' + required: true + remotepath: + description: 'The remote path to sync' + required: true +runs: + using: 'docker' + image: 'Dockerfile' +branding: + icon: 'truck' + color: 'yellow' From c0b37b3d95f43f00501b59fe430527570681eb7b Mon Sep 17 00:00:00 2001 From: Contention Date: Fri, 24 Mar 2023 19:40:17 +0000 Subject: [PATCH 08/11] Update entrypoint.sh --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 9ab8325..79d7baf 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -10,4 +10,4 @@ chmod 600 "$SSH_PATH/deploy_key" # Do deployment -sh -c "rsync $FLAGS -e 'ssh -i $SSH_PATH/deploy_key -o StrictHostKeyChecking=no' $EXCLUDES $GITHUB_WORKSPACE/$LOCALPATH $USER@$HOST:$REMOTEPATH" +sh -c "rsync $INPUT_FLAGS -e 'ssh -i $SSH_PATH/deploy_key -o StrictHostKeyChecking=no' $INPUT_EXCLUDES $GITHUB_WORKSPACE/$INPUT_LOCALPATH $INPUT_USER@$INPUT_HOST:$INPUT_REMOTEPATH" From a51ddb22fb530ceabcd5c6b31ef805db85dac65c Mon Sep 17 00:00:00 2001 From: Contention Date: Fri, 24 Mar 2023 21:09:24 +0000 Subject: [PATCH 09/11] Update entrypoint.sh --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 79d7baf..8fa0846 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,7 +5,7 @@ set -eu # Set deploy key SSH_PATH="$HOME/.ssh" mkdir "$SSH_PATH" -echo "$DEPLOY_KEY" > "$SSH_PATH/deploy_key" +echo "$INPUT_DEPLOY_KEY" > "$SSH_PATH/deploy_key" chmod 600 "$SSH_PATH/deploy_key" From 2818ab45e9816fe443eaf1fb1feec36424308ef4 Mon Sep 17 00:00:00 2001 From: Contention Date: Fri, 24 Mar 2023 21:12:03 +0000 Subject: [PATCH 10/11] Update action.yml --- action.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/action.yml b/action.yml index 38a9e9a..731040e 100644 --- a/action.yml +++ b/action.yml @@ -20,6 +20,9 @@ inputs: remotepath: description: 'The remote path to sync' required: true + deploy_key: + description: 'The private key' + required: true runs: using: 'docker' image: 'Dockerfile' From ac11b74215b5f8b2fca46ffcb7b2f6cd9304c41e Mon Sep 17 00:00:00 2001 From: Contention Date: Fri, 24 Mar 2023 21:27:03 +0000 Subject: [PATCH 11/11] Update README.md --- README.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 9400e1f..de03d52 100644 --- a/README.md +++ b/README.md @@ -16,11 +16,11 @@ This action requires six inputs: 2. `EXCLUDES` for any `--exclude` flags and directory pairs, eg: `--exclude .htaccess --exclude /uploads/`. Use `""` if none required. -3. `USER` for the deployment target, and should be in the format: `deploybot` +3. `USER` for the server user, eg: `deploybot` -4. `HOST` for the server user, eg: `myserver.com` +4. `HOST` for the deployment target, eg: `myserver.com` -5. `LOCALPATH` for the local path to sync, eg: `/dist` +5. `LOCALPATH` for the local path to sync, eg: `/dist/` 5. `REMOTEPATH` for the remote path to sync, eg: `/srv/myapp/public/htdocs/` @@ -45,9 +45,8 @@ jobs: EXCLUDES: --exclude .htaccess --exclude /uploads/ USER deploybot HOST: myserver.com - LOCALPATH: /dist - DEST: /srv/myapp/public/htdocs/ - env: + LOCALPATH: /dist/ + REMOTEPATH: /srv/myapp/public/htdocs/ DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }} ```