mirror of
https://gitee.com/jiulinxiri/rsync-deployments.git
synced 2025-09-11 02:12:25 +08:00
Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
10f98a8726 | ||
|
ac11b74215 | ||
|
2818ab45e9 | ||
|
a51ddb22fb | ||
|
c0b37b3d95 | ||
|
016e24df53 | ||
|
e79da04402 | ||
|
a0a657cdc1 | ||
|
a5bf1cc70f | ||
|
862fef3e69 | ||
|
b111bee195 | ||
|
891175368a | ||
|
65ac047ad6 |
16
Dockerfile
16
Dockerfile
@@ -1,22 +1,14 @@
|
|||||||
FROM debian:9.5-slim
|
FROM drinternet/rsync:v1.4.3
|
||||||
|
|
||||||
|
|
||||||
# Update
|
|
||||||
RUN apt-get update
|
|
||||||
|
|
||||||
|
|
||||||
# Install packages
|
|
||||||
RUN apt-get -yq install rsync openssh-client
|
|
||||||
|
|
||||||
|
|
||||||
# Label
|
# Label
|
||||||
LABEL "com.github.actions.name"="rsync deployments"
|
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.icon"="truck"
|
||||||
LABEL "com.github.actions.color"="yellow"
|
LABEL "com.github.actions.color"="yellow"
|
||||||
|
|
||||||
LABEL "repository"="http://github.com/contention/action-rsync-deploy"
|
LABEL "repository"="http://github.com/contention/rsync-deployments"
|
||||||
LABEL "homepage"="https://github.com/contention/action-rsync-deploy"
|
LABEL "homepage"="https://github.com/contention/rsync-deployments"
|
||||||
LABEL "maintainer"="Contention <hello@contention.agency>"
|
LABEL "maintainer"="Contention <hello@contention.agency>"
|
||||||
|
|
||||||
|
|
||||||
|
56
README.md
56
README.md
@@ -1,40 +1,56 @@
|
|||||||
# rsync deployments
|
# 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`.
|
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.
|
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 server user, eg: `deploybot`
|
||||||
|
|
||||||
|
4. `HOST` for the deployment target, eg: `myserver.com`
|
||||||
|
|
||||||
|
5. `LOCALPATH` for the local path to sync, eg: `/dist/`
|
||||||
|
|
||||||
|
5. `REMOTEPATH` for the remote path to sync, eg: `/srv/myapp/public/htdocs/`
|
||||||
|
|
||||||
# Example usage
|
# Example usage
|
||||||
|
|
||||||
```
|
```
|
||||||
workflow "All pushes" {
|
name: Deploy to production
|
||||||
on = "push"
|
|
||||||
resolves = ["Deploy to Staging"]
|
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 --exclude /uploads/
|
||||||
|
USER deploybot
|
||||||
|
HOST: myserver.com
|
||||||
|
LOCALPATH: /dist/
|
||||||
|
REMOTEPATH: /srv/myapp/public/htdocs/
|
||||||
|
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
|
||||||
|
|
||||||
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/"]
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Disclaimer
|
## REMINDER!
|
||||||
|
|
||||||
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.
|
Check your keys. Check your deployment paths. Check your flags. And use at your own risk.
|
||||||
|
|
||||||
So, check your keys. Check your deployment paths. And use at your own risk.
|
|
||||||
|
31
action.yml
Normal file
31
action.yml
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
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
|
||||||
|
deploy_key:
|
||||||
|
description: 'The private key'
|
||||||
|
required: true
|
||||||
|
runs:
|
||||||
|
using: 'docker'
|
||||||
|
image: 'Dockerfile'
|
||||||
|
branding:
|
||||||
|
icon: 'truck'
|
||||||
|
color: 'yellow'
|
@@ -5,9 +5,9 @@ set -eu
|
|||||||
# Set deploy key
|
# Set deploy key
|
||||||
SSH_PATH="$HOME/.ssh"
|
SSH_PATH="$HOME/.ssh"
|
||||||
mkdir "$SSH_PATH"
|
mkdir "$SSH_PATH"
|
||||||
echo "$DEPLOY_KEY" > "$SSH_PATH/deploy_key"
|
echo "$INPUT_DEPLOY_KEY" > "$SSH_PATH/deploy_key"
|
||||||
chmod 600 "$SSH_PATH/deploy_key"
|
chmod 600 "$SSH_PATH/deploy_key"
|
||||||
|
|
||||||
|
|
||||||
# Do deployment
|
# Do deployment
|
||||||
sh -c "rsync $1 -e 'ssh -i $SSH_PATH/deploy_key -o StrictHostKeyChecking=no' $2 $GITHUB_WORKSPACE/ $3"
|
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"
|
||||||
|
Reference in New Issue
Block a user