Compare commits

..

17 Commits

Author SHA1 Message Date
Steven Agyekum febcb5ac34 Update README.md 2019-12-04 19:11:03 +01:00
Steven Agyekum 682623851b Update README.md 2019-12-04 19:09:24 +01:00
Steven Agyekum 050c29bcea Update README.md 2019-12-04 19:06:58 +01:00
Steven Agyekum 6093fd5ca1 Update README.md 2019-12-04 19:02:32 +01:00
Steven Agyekum 0186c3a6b2 added INPUT_REMOTE_PORT input for different port 2019-12-04 19:00:33 +01:00
Steven Agyekum 2f8edbc7f1 Update README.md 2019-12-04 18:58:49 +01:00
Steven Agyekum d573c19867 Update action.yml 2019-12-04 18:58:23 +01:00
Steven Agyekum 609b9969e2 version 2.0
Feature/version 2.0
2019-12-04 18:50:21 +01:00
Steven Agyekum 1e3e469683 Merge branch 'master' into feature/version-2.0 2019-12-04 18:48:51 +01:00
Steven Agyekum 6b3db75d87 Update README.md 2019-12-04 18:41:36 +01:00
Steven Agyekum c4c3b6821b Update README.md 2019-12-04 18:39:07 +01:00
Steven Agyekum 2f0d5a19fa Update README.md 2019-12-04 18:37:11 +01:00
Steven Agyekum 5536ad8c42 Update README.md 2019-12-04 18:35:52 +01:00
Steven Agyekum e9dd3cdb51 new inputs 2019-12-04 18:31:26 +01:00
Steven Agyekum 72f04677de new inputs and shell 2019-12-04 18:29:34 +01:00
Steven Agyekum 1eb5088cc2 Mention new inputs, added more examples, removed disclaimer 2019-12-04 18:28:33 +01:00
Steven Agyekum 24cfa35ecb remove docker labeling 2019-12-04 18:26:19 +01:00
4 changed files with 108 additions and 43 deletions
-15
View File
@@ -1,27 +1,12 @@
FROM ubuntu:latest
# Update
RUN apt-get update
# Install packages
RUN apt-get -yq install rsync openssh-client
# 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.icon"="truck"
LABEL "com.github.actions.color"="yellow"
LABEL "repository"="https://github.com/Burnett01/rsync-deployments"
LABEL "homepage"="https://github.com/Burnett01/rsync-deployments"
LABEL "maintainer"="Contention <hello@contention.agency> & Burnett01"
# Copy entrypoint
ADD entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
+86 -20
View File
@@ -7,23 +7,35 @@ This GitHub Action deploys files in `GITHUB_WORKSPACE` to a folder on a server v
Use this action in a build/test workflow which leaves deployable code in `GITHUB_WORKSPACE`.
# Required SECRETs
---
This action needs a `DEPLOY_KEY` secret variable. This should be the private key part of a ssh key pair. The public key part should be added to the authorized_keys file on the server that receives the deployment. This should be set in the Github secrets section and then referenced as an `env` variable.
## Inputs
# ARGs
- `switches`* - The first is for any initial/required rsync flags, eg: `-avzr --delete`
This action requires 4 args in the `with` block.
- `rsh` - Remote shell commands
1. `swtiches` - The first is for any initial/required rsync flags, eg: `-avzr --delete`
- `path` - The source path. Defaults to GITHUB_WORKSPACE
2. `rsh` - Remote shell commands, eg for using a different SSH port: `"-p ${{ secrets.DEPLOY_PORT }}"`
- `remote_path`* - The deployment target path
3. `path` - The source path, if none; use `""`
- `remote_host`* - The remote host
4. `upload_path` - The deployment target, and should be in the format: `[USER]@[HOST]:[PATH]`
- `remote_port` - The remote port. Defaults to 22
# Example usage
- `remote_user`* - The remote user
- `remote_key`* - The remote ssh key
``* = Required``
## Required secret
This action needs a `DEPLOY_KEY` secret variable. This should be the private key part of a ssh key pair. The public key part should be added to the authorized_keys file on the server that receives the deployment. This should be set in the Github secrets section and then referenced as the `remote_key` input.
## Example usage
Simple:
```
name: DEPLOY
@@ -38,20 +50,74 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: rsync deployments
uses: burnett01/rsync-deployments@1.0
uses: burnett01/rsync-deployments@2.0
with:
switches: -avzr --delete --exclude="" --include=""
rsh: "-p ${{ secrets.DEPLOY_PORT }}"
switches: -avzr --delete
path: src/
upload_path: user@example.com:/var/www/html/
env:
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
remote_path: /var/www/html/
remote_host: example.com
remote_user: debian
remote_key: ${{ secrets.DEPLOY_KEY }}
```
## Disclaimer
Advanced:
If you're using GitHub Actions, you probably already know that it's still in limited public beta, and GitHub advise against using Actions in production.
```
name: DEPLOY
on:
push:
branches:
- master
So, check your keys. Check your deployment paths. And use at your own risk.
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: rsync deployments
uses: burnett01/rsync-deployments@2.0
with:
switches: -avzr --delete --exclude="" --include="" --filter=""
path: src/
remote_path: /var/www/html/
remote_host: example.com
remote_port: 5555
remote_user: debian
remote_key: ${{ secrets.DEPLOY_KEY }}
```
For better security, I suggest you create additional secrets for remote_host, remote_port and remote_user inputs.
```
name: DEPLOY
on:
push:
branches:
- master
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: rsync deployments
uses: burnett01/rsync-deployments@2.0
with:
switches: -avzr --delete
path: src/
remote_path: /var/www/html/
remote_host: ${{ secrets.DEPLOY_HOST }}
remote_port: ${{ secrets.DEPLOY_PORT }}
remote_user: ${{ secrets.DEPLOY_USER }}
remote_key: ${{ secrets.DEPLOY_KEY }}
```
---
## Version 1.0 (EOL)
Looking for version 1.0?
Check here: https://github.com/Burnett01/rsync-deployments/tree/1.0
Please note that version 1.0 has reached end of life state.
+14 -1
View File
@@ -13,9 +13,22 @@ inputs:
description: 'The local path'
required: false
default: ''
upload_path:
remote_path:
description: 'The remote path'
required: true
remote_host:
description: 'The remote host'
required: true
remote_port:
description: 'The remote port'
required: false
default: 22
remote_user:
description: 'The remote user'
required: true
remote_key:
description: 'The remote key'
required: true
runs:
using: 'docker'
image: 'Dockerfile'
+8 -7
View File
@@ -1,17 +1,18 @@
#!/bin/sh
#!/bin/bash
set -eu
# Set deploy key
SSH_PATH="$HOME/.ssh"
# Create .ssh dir if it doesn't exist
if [ ! -d "$SSH_PATH" ]; then
mkdir "$SSH_PATH"
fi
[ -d "$SSH_PATH" ] || mkdir "$SSH_PATH"
# Place deploy_key into .ssh dir
echo "$DEPLOY_KEY" > "$SSH_PATH/deploy_key"
echo "$INPUT_REMOTE_KEY" > "$SSH_PATH/key"
# Set r+w to user only
chmod 600 "$SSH_PATH/deploy_key"
chmod 600 "$SSH_PATH/key"
# Do deployment
sh -c "rsync $INPUT_SWITCHES -e 'ssh -i $SSH_PATH/deploy_key -o StrictHostKeyChecking=no $INPUT_RSH' $GITHUB_WORKSPACE/$INPUT_PATH $INPUT_UPLOAD_PATH"
sh -c "rsync $INPUT_SWITCHES -e 'ssh -i $SSH_PATH/key -o StrictHostKeyChecking=no -p $INPUT_REMOTE_PORT $INPUT_RSH' $GITHUB_WORKSPACE/$INPUT_PATH $INPUT_REMOTE_USER@$INPUT_REMOTE_HOST:$INPUT_REMOTE_PATH"