├── Dockerfile ├── README.md └── entrypoint.sh /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:stable-slim 2 | 3 | RUN apt update 4 | RUN apt -yq install rsync openssh-client 5 | 6 | 7 | # Label 8 | LABEL "com.github.actions.name"="Deploy with rsync" 9 | LABEL "com.github.actions.description"="Deploy to a remote server using rsync over ssh" 10 | LABEL "com.github.actions.color"="green" 11 | LABEL "com.github.actions.icon"="truck" 12 | 13 | LABEL "repository"="http://github.com/AEnterprise/rsync-deploy" 14 | LABEL "homepage"="https://github.com/AEnterprise/rsync-deploy" 15 | LABEL "maintainer"="AEnterprise " 16 | 17 | 18 | ADD entrypoint.sh /entrypoint.sh 19 | RUN chmod +x /entrypoint.sh 20 | ENTRYPOINT ["/entrypoint.sh"] 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # rsync-deploy 2 | 3 | Deploy to a remote server using rsync. 4 | 5 | example usage to sync everything in the workspace folder: 6 | ``` 7 | - name: deploy to server 8 | uses: AEnterprise/rsync-deploy@v1.0.2 9 | env: 10 | DEPLOY_KEY: ${{ secrets.SERVER_SSH_KEY }} 11 | ARGS: "-e -c -r --delete" 12 | SERVER_PORT: ${{ secrets.SERVER_PORT }} 13 | FOLDER: "./" 14 | SERVER_IP: ${{ secrets.SERVER_IP }} 15 | USERNAME: ${{ secrets.USERNAME }} 16 | SERVER_DESTINATION: ${{ secrets.SERVER_DESTINATION }} 17 | ``` 18 | 19 | If you only want to sync a specific subfolder you can put that folder in the folder env var instead 20 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -eu 3 | 4 | SSHPATH="$HOME/.ssh" 5 | if [ ! -d "$SSHPATH" ]; then 6 | mkdir -p "$SSHPATH" 7 | fi 8 | echo "$DEPLOY_KEY" > "$SSHPATH/key" 9 | chmod 600 "$SSHPATH/key" 10 | SERVER_DEPLOY_STRING="$USERNAME@$SERVER_IP:$SERVER_DESTINATION" 11 | # sync it up" 12 | sh -c "rsync $ARGS -e 'ssh -i $SSHPATH/key -o StrictHostKeyChecking=no -p $SERVER_PORT' $GITHUB_WORKSPACE/$FOLDER $SERVER_DEPLOY_STRING" 13 | --------------------------------------------------------------------------------