[init]: update `env` vars

main
Dragan Filipovic 2019-09-25 23:52:29 +02:00
parent 544c80dc4a
commit 1d834c8cd1
2 changed files with 51 additions and 18 deletions

View File

@ -4,35 +4,68 @@ This GitHub Action deploys specific directory from `GITHUB_WORKSPACE` to a folde
This action would usually follow a build/test action which leaves deployable code in `GITHUB_WORKSPACE`, eg `dist`; This action would usually follow a build/test action which leaves deployable code in `GITHUB_WORKSPACE`, eg `dist`;
# Required SECRETs # Configuration
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. Pass configuration with `env` vars
# Required ARGs 1. `DEPLOY_KEY`
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 can receive three `ARG`s: 2. `ARGS`
For any initial/required rsync flags, eg: `-avzr --delete`
1. The first is for any initial/required rsync flags, eg: `-avzr --delete` 3. `SOURCE`
The source directory, path relative to `$GITHUB_WORKSPACE` root, eg: `dist`
2. The second is for any `--exclude` flags and directory pairs, eg: `--exclude .htaccess --exclude /uploads/`. Use "" if none required. 4. `TARGET`
The target directory, in the format`[USER]@[HOST]:[PATH]`
3. The third is for the source target, path relative to `$GITHUB_WORKSPACE` root, eg: `dist`
4. The fourth is for the deployment target, and should be in the format: `[USER]@[HOST]:[PATH]` ```
- name: Deploy to Staging server
uses: easingthemes/ssh-deploy@v1.0
env:
DEPLOY_KEY: ${{ secrets.SERVER_SSH_KEY }}
ARGS: "-rltgoDzvO --delete"
SOURCE: "dist"
TARGET: ${{ secrets.SERVER_STAGING }}
```
# Example usage # Example usage
``` ```
workflow "All pushes" { name: Node CI
on = "push"
resolves = ["Deploy to Staging"]
}
action "Deploy to Staging" { on: [push]
uses = "contention/action-rsync-deploy@master"
secrets = ["DEPLOY_KEY"] jobs:
args = ["-avzr --delete", "--exclude .htaccess --exclude /uploads/", "user@server.com:/srv/myapp/public/htdocs/"] build:
}
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install npm dependencies
run: |
npm install
- name: Run build task
run: |
npm run build --if-present
- name: Deploy to Staging server
uses: easingthemes/ssh-deploy@v1.0
env:
DEPLOY_KEY: ${{ secrets.SERVER_SSH_KEY }}
ARGS: "-rltgoDzvO --delete"
SOURCE: "dist"
TARGET: ${{ secrets.SERVER_STAGING }}
``` ```
## Disclaimer ## Disclaimer

View File

@ -10,4 +10,4 @@ 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 $4" sh -c "rsync $ARGS -e 'ssh -i $SSH_PATH/deploy_key -o StrictHostKeyChecking=no' $GITHUB_WORKSPACE/$SOURCE $TARGET"