Skip to content

Commit 10f98a8

Browse files
authored
Merge pull request #11 from contention/v2-dev
V2 dev
2 parents 65ac047 + ac11b74 commit 10f98a8

File tree

4 files changed

+72
-33
lines changed

4 files changed

+72
-33
lines changed

Dockerfile

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
1-
FROM debian:9.5-slim
2-
3-
4-
# Update
5-
RUN apt-get update
6-
7-
8-
# Install packages
9-
RUN apt-get -yq install rsync openssh-client
1+
FROM drinternet/rsync:v1.4.3
102

113

124
# Label
135
LABEL "com.github.actions.name"="rsync deployments"
14-
LABEL "com.github.actions.description"="For deploying code to a webserver via rsync over ssh"
6+
LABEL "com.github.actions.description"="Quick and simple method of deploying code to a webserver via rsync over ssh"
157
LABEL "com.github.actions.icon"="truck"
168
LABEL "com.github.actions.color"="yellow"
179

README.md

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,56 @@
11
# rsync deployments
22

3-
This GitHub Action deploys *everything* in `GITHUB_WORKSPACE` to a folder on a server via rsync over ssh.
3+
This GitHub Action deploys files in `GITHUB_WORKSPACE` to a folder on a server via rsync over ssh.
44

55
This action would usually follow a build/test action which leaves deployable code in `GITHUB_WORKSPACE`.
66

7-
# Required SECRETs
7+
# Required secrets
88

99
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.
1010

11-
# Required ARGs
11+
# Required inputs
1212

13-
This action can receive three `ARG`s:
13+
This action requires six inputs:
1414

15-
1. The first is for any initial/required rsync flags, eg: `-avzr --delete`
15+
1. `FLAGS` for any initial/required rsync flags, eg: `-avzr --delete`
1616

17-
2. The second is for any `--exclude` flags and directory pairs, eg: `--exclude .htaccess --exclude /uploads/`. Use "" if none required.
17+
2. `EXCLUDES` for any `--exclude` flags and directory pairs, eg: `--exclude .htaccess --exclude /uploads/`. Use `""` if none required.
1818

19-
3. The third is for the deployment target, and should be in the format: `[USER]@[HOST]:[PATH]`
19+
3. `USER` for the server user, eg: `deploybot`
20+
21+
4. `HOST` for the deployment target, eg: `myserver.com`
22+
23+
5. `LOCALPATH` for the local path to sync, eg: `/dist/`
24+
25+
5. `REMOTEPATH` for the remote path to sync, eg: `/srv/myapp/public/htdocs/`
2026

2127
# Example usage
2228

2329
```
24-
workflow "All pushes" {
25-
on = "push"
26-
resolves = ["Deploy to Staging"]
27-
}
28-
29-
action "Deploy to Staging" {
30-
uses = "contention/action-rsync-deploy@master"
31-
secrets = ["DEPLOY_KEY"]
32-
args = ["-avzr --delete", "--exclude .htaccess --exclude /uploads/", "[email protected]:/srv/myapp/public/htdocs/"]
33-
}
34-
```
30+
name: Deploy to production
31+
32+
on:
33+
push:
34+
branches:
35+
- master
36+
37+
jobs:
38+
deploy:
39+
runs-on: ubuntu-latest
40+
steps:
41+
- uses: actions/checkout@v2
42+
- uses: contention/[email protected]
43+
with:
44+
FLAGS: -avzr --delete
45+
EXCLUDES: --exclude .htaccess --exclude /uploads/
46+
USER deploybot
47+
HOST: myserver.com
48+
LOCALPATH: /dist/
49+
REMOTEPATH: /srv/myapp/public/htdocs/
50+
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
3551
36-
## Disclaimer
52+
```
3753

38-
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.
54+
## REMINDER!
3955

40-
So, check your keys. Check your deployment paths. And use at your own risk.
56+
Check your keys. Check your deployment paths. Check your flags. And use at your own risk.

action.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: 'rsync deployments'
2+
description: 'Quick and simple method of deploying code to a webserver via rsync over ssh'
3+
author: 'Contention'
4+
inputs:
5+
flags:
6+
description: 'Initial/required rsync flags'
7+
required: true
8+
excludes:
9+
description: 'Exclude flags and directory pairs'
10+
required: true
11+
user:
12+
description: 'The server user'
13+
required: true
14+
host:
15+
description: 'The deployment target'
16+
required: true
17+
localpath:
18+
description: 'The local path to sync'
19+
required: true
20+
remotepath:
21+
description: 'The remote path to sync'
22+
required: true
23+
deploy_key:
24+
description: 'The private key'
25+
required: true
26+
runs:
27+
using: 'docker'
28+
image: 'Dockerfile'
29+
branding:
30+
icon: 'truck'
31+
color: 'yellow'

entrypoint.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ set -eu
55
# Set deploy key
66
SSH_PATH="$HOME/.ssh"
77
mkdir "$SSH_PATH"
8-
echo "$DEPLOY_KEY" > "$SSH_PATH/deploy_key"
8+
echo "$INPUT_DEPLOY_KEY" > "$SSH_PATH/deploy_key"
99
chmod 600 "$SSH_PATH/deploy_key"
1010

1111

1212
# Do deployment
13-
sh -c "rsync $1 -e 'ssh -i $SSH_PATH/deploy_key -o StrictHostKeyChecking=no' $2 $GITHUB_WORKSPACE/ $3"
13+
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"

0 commit comments

Comments
 (0)