|
1 | 1 | # rsync deployments |
2 | 2 |
|
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. |
4 | 4 |
|
5 | 5 | This action would usually follow a build/test action which leaves deployable code in `GITHUB_WORKSPACE`. |
6 | 6 |
|
7 | | -# Required SECRETs |
| 7 | +# Required secrets |
8 | 8 |
|
9 | 9 | 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. |
10 | 10 |
|
11 | | -# Required ARGs |
| 11 | +# Required inputs |
12 | 12 |
|
13 | | -This action can receive three `ARG`s: |
| 13 | +This action requires six inputs: |
14 | 14 |
|
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` |
16 | 16 |
|
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. |
18 | 18 |
|
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/` |
20 | 26 |
|
21 | 27 | # Example usage |
22 | 28 |
|
23 | 29 | ``` |
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 }} |
35 | 51 |
|
36 | | -## Disclaimer |
| 52 | +``` |
37 | 53 |
|
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! |
39 | 55 |
|
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. |
0 commit comments