Repository: contention/rsync-deployments Branch: master Commit: 10f98a8726e6 Files: 5 Total size: 4.3 KB Directory structure: gitextract_sp5hyijq/ ├── Dockerfile ├── LICENSE ├── README.md ├── action.yml └── entrypoint.sh ================================================ FILE CONTENTS ================================================ ================================================ FILE: Dockerfile ================================================ FROM drinternet/rsync:v1.4.3 # Label LABEL "com.github.actions.name"="rsync deployments" 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.color"="yellow" LABEL "repository"="http://github.com/contention/rsync-deployments" LABEL "homepage"="https://github.com/contention/rsync-deployments" LABEL "maintainer"="Contention " # Copy entrypoint ADD entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) 2019 Contention Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ # rsync deployments 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`. # 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. # Required inputs This action requires six inputs: 1. `FLAGS` for any initial/required rsync flags, eg: `-avzr --delete` 2. `EXCLUDES` for any `--exclude` flags and directory pairs, eg: `--exclude .htaccess --exclude /uploads/`. Use `""` if none required. 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 ``` name: Deploy to production 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 }} ``` ## REMINDER! Check your keys. Check your deployment paths. Check your flags. And use at your own risk. ================================================ FILE: action.yml ================================================ 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' ================================================ FILE: entrypoint.sh ================================================ #!/bin/sh set -eu # Set deploy key SSH_PATH="$HOME/.ssh" mkdir "$SSH_PATH" echo "$INPUT_DEPLOY_KEY" > "$SSH_PATH/deploy_key" chmod 600 "$SSH_PATH/deploy_key" # Do deployment 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"