Code Monkey home page Code Monkey logo

rsync-deployments's Introduction

rsync deployments

This GitHub Action (amd64) deploys files in GITHUB_WORKSPACE to a remote folder via rsync over ssh.

Use this action in a CD workflow which leaves deployable code in GITHUB_WORKSPACE.

The base-image drinternet/rsync of this action is very small and is based on Alpine 3.19.1 (no cache) which results in fast deployments.


Inputs

  • switches* - The first is for any initial/required rsync flags, eg: -avzr --delete

  • rsh - Remote shell commands

  • legacy_allow_rsa_hostkeys - Enables support for legacy RSA host keys on OpenSSH 8.8+. ("true" / "false")

  • path - The source path. Defaults to GITHUB_WORKSPACE and is relative to it

  • remote_path* - The deployment target path

  • remote_host* - The remote host

  • remote_port - The remote port. Defaults to 22

  • remote_user* - The remote user

  • remote_key* - The remote ssh key

  • remote_key_pass - The remote ssh key passphrase (if any)

* = Required

Required secret(s)

This action needs secret variables for the ssh private key of your key pair. The public key part should be added to the authorized_keys file on the server that receives the deployment. The secret variable should be set in the Github secrets section of your org/repo and then referenced as the remote_key input.

Always use secrets when dealing with sensitive inputs!

For simplicity, we are using DEPLOY_* as the secret variables throughout the examples.

Current Version: 7.0.1

Example usage

Simple:

name: DEPLOY
on:
  push:
    branches:
    - master

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: rsync deployments
      uses: burnett01/[email protected]
      with:
        switches: -avzr --delete
        path: src/
        remote_path: /var/www/html/
        remote_host: example.com
        remote_user: debian
        remote_key: ${{ secrets.DEPLOY_KEY }}

Advanced:

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: rsync deployments
      uses: burnett01/[email protected]
      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, remote_user and remote_path inputs.

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: rsync deployments
      uses: burnett01/[email protected]
      with:
        switches: -avzr --delete
        path: src/
        remote_path: ${{ secrets.DEPLOY_PATH }}
        remote_host: ${{ secrets.DEPLOY_HOST }}
        remote_port: ${{ secrets.DEPLOY_PORT }}
        remote_user: ${{ secrets.DEPLOY_USER }}
        remote_key: ${{ secrets.DEPLOY_KEY }}

If your private key is passphrase protected you should use:

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: rsync deployments
      uses: burnett01/[email protected]
      with:
        switches: -avzr --delete
        path: src/
        remote_path: ${{ secrets.DEPLOY_PATH }}
        remote_host: ${{ secrets.DEPLOY_HOST }}
        remote_port: ${{ secrets.DEPLOY_PORT }}
        remote_user: ${{ secrets.DEPLOY_USER }}
        remote_key: ${{ secrets.DEPLOY_KEY }}
        remote_key_pass: ${{ secrets.DEPLOY_KEY_PASS }}

Legacy RSA Hostkeys support for OpenSSH Servers >= 8.8+

If your remote OpenSSH Server still uses RSA hostkeys, then you have to manually enable legacy support for this by using legacy_allow_rsa_hostkeys: "true".

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: rsync deployments
      uses: burnett01/[email protected]
      with:
        switches: -avzr --delete
        legacy_allow_rsa_hostkeys: "true"
        path: src/
        remote_path: ${{ secrets.DEPLOY_PATH }}
        remote_host: ${{ secrets.DEPLOY_HOST }}
        remote_port: ${{ secrets.DEPLOY_PORT }}
        remote_user: ${{ secrets.DEPLOY_USER }}
        remote_key: ${{ secrets.DEPLOY_KEY }}

See #49 and #24 for more information.


Version 6.0 (MAINTENANCE)

Check here:


Version 5.0, 5.1 & 5.2 & 5.x (DEPRECATED)

Check here:


Version 4.0 & 4.1 (EOL)

Check here:

Version 4.0 & 4.1 use the drinternet/rsync:1.0.1 base-image.


Version 3.0 (EOL)

Check here: https://github.com/Burnett01/rsync-deployments/tree/3.0

Version 3.0 uses the alpine:latest base-image directly.
Consider upgrading to 4.0 that uses a docker-image drinternet/rsync:1.0.1 that is
based on alpine:latestand heavily optimized for rsync.

Version 2.0 (EOL)

Check here: https://github.com/Burnett01/rsync-deployments/tree/2.0

Version 2.0 uses a larger base-image (ubuntu:latest).
Consider upgrading to 3.0 for even faster deployments.

Version 1.0 (EOL)

Check here: https://github.com/Burnett01/rsync-deployments/tree/1.0

Please note that version 1.0 has reached end of life state.


Acknowledgements


Media

This action was featured in multiple blogs across the globe:

Disclaimer: The author & co-authors are not responsible for the content of the site-links below.

rsync-deployments's People

Contributors

burnett01 avatar contention avatar dependabot[bot] avatar jasongill avatar joshpiper avatar xcomp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

rsync-deployments's Issues

rsync Not Found?

Getting a very unexpected error when Github actions execute:

Identity added: (stdin) (admin@*****.com)
Warning: Permanently added '***' (ED25519) to the list of known hosts.
ksh: rsync: not found
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code [12](https://github.com/jrswab/guild/actions/runs/7856477062/job/21439281458#step:4:13)) at io.c(231) [sender=3.2.7]

Here is what I have in my Github actions file:

  deploy:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - name: Deploy with rsync
      uses: burnett01/[email protected]
      with:
        switches: -avzr
        path: guild-${{ github.ref_name }}
        remote_path: /home/builds/guild-${{ github.ref_name }}
        remote_host: ${{ secrets.SSH_HOST }}
        remote_user: ${{ secrets.SSH_USER }}
        remote_key: ${{ secrets.SSH_PRIVATE_KEY }}

Any insight would be greatly appreciated as to why it's telling me rsync not found.

Can I use password?

Hi! I try to use your action for deploy, but I have error "Permission denied" because I need to input password (It said hosting provider). Is it possible with you action? Or maybe I do something wrong

Screenshot_1

Code:

name: DEPLOY
on:
  push:
    branches:
    - master

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: rsync deployments
      uses: burnett01/[email protected]
      with:
        switches: -avzr --delete
        path: dist/
        remote_path: /test/
        remote_host: *ip*
        remote_user: *username*
        remote_key: ${{ secrets.KEY }}

SSH key wrong when it isn't

Hello, the program says the key is wrong when it isn't (I use the same key to connect over ssh)

      - name: Checkout sources
        uses: actions/checkout@v2
      - name: Copy binary with rsync
        uses: burnett01/[email protected]
        with:
          switches: -avzr -vvv
          path: target/release/microprogress
          remote_path: ${{ secrets.PATH }}
          remote_host: ${{ secrets.HOST }}
          remote_user: $${{ secrets.USERNAME }}
          remote_key: ${{ secrets.KEY }}

This is the message when ran with -vvv:


Run burnett01/[email protected]
/usr/bin/docker run --name bec5f4281d335037d4d46a6e33953a96d00d2_cea912 --label 3bec5f --workdir /github/workspace --rm -e INPUT_SWITCHES -e INPUT_PATH -e INPUT_REMOTE_PATH -e INPUT_REMOTE_HOST -e INPUT_REMOTE_USER -e INPUT_REMOTE_KEY -e INPUT_RSH -e INPUT_REMOTE_PORT -e INPUT_REMOTE_KEY_PASS -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/microprogress/microprogress":"/github/workspace" 3bec5f:4281d335037d4d46a6e33953a96d00d2
Identity added: (stdin) ((stdin))
cmd=ssh -o StrictHostKeyChecking=no -p 22  machine=*** user= path=***
cmd[0]=ssh cmd[1]=-o cmd[2]=StrictHostKeyChecking=no cmd[3]=-p cmd[4]=22 cmd[5]=-l cmd[6]= cmd[7]=*** cmd[8]=rsync cmd[9]=--server cmd[10]=-vvvvlogDtprze.iLsfxC cmd[11]=. cmd[12]=*** 
opening connection using: ssh -o StrictHostKeyChecking=no -p 22 -l  *** rsync --server -vvvvlogDtprze.iLsfxC . ***  (13 args)
msg checking charset: UTF-8
Warning: Permanently added '***' (ECDSA) to the list of known hosts.
@***: Permission denied (publickey).
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
[sender] _exit_cleanup(code=12, file=io.c, line=226): entered
[sender] _exit_cleanup(code=12, file=io.c, line=226): about to call exit(12)
rsync error: error in rsync protocol data stream (code 12) at io.c(226) [sender=3.1.3]```

Fails inside containers due to reliance on $GITHUB_WORKSPACE

This action does not work inside containers, as paths can only be relative to $GITHUB_WORKSPACE. Current workaround is to copy files that need to be rsync-ed from the container directory to $GITHUB_WORKSPACE. Suggest allowing absolute paths to be used by prefixing the path variable with a forward slash /.

Keep images folder between deploys

I have images folder on my website which stores user's uploaded images so that I want to keep this folder between deploys to not be deleted with sync.
Is there a way to achieve that??

-F is not working

Hello,

I'm trying to use one of those:

  • switches: -avzrF --delete
  • switches: -avzrFF --delete
  • switches: -avzr --filter=': back/.rsync-filter' --delete

But none is working: my filter file is not taken into account.
By taking a look at entrypoint.sh, I suppose it is because you first ssh into the server and then execute rsync.
Would it be possible to do something like so?

rsync $SWITCHES $LOCAL_PATH rsync://$INPUT_REMOTE_USER@$INPUT_REMOTE_HOST:$INPUT_REMOTE_PORT/$INPUT_REMOTE_PATH

?

sync

It is syncying all the files including non incremental files even if I used rsync with -avzr option !

Rsync Error

when i deploy a project to server , i got this error in log.
But everything is going well, no files are missing. It's just the red error symbol that annoys on me

sorry for my bad English ๐Ÿ˜ข

rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1189) [sender=3.1.3]

invalid format

I'm getting this error

Error loading key "(stdin)": invalid format
ssh: Could not resolve hostname : Name does not resolve
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(228) [sender=3.2.3]

what is the correct format ?
my current key starts with -----BEGIN RSA PRIVATE KEY----- ... -----END RSA PRIVATE KEY-----

i'm trying to get into my EC2 instance, so the whole setup looks like this:

      - uses: actions/checkout@v2
      - name: rsync deployments
        uses: burnett01/[email protected]
        with:
          switches: -avzhe --exclude-from 'exclude.txt'
          path: ./
          remote_path: /var/www/html/
          remote_host: ${{ secrets.HOST }}
          remote_user: ec2-user
          remote_key: ${{ secrets.DEPLOY_KEY }}

Not removing delete files on server

If i delete/rename a file on my repository from local and push it to Github, It's not deleting/renaming on server. I attached my exact code below. Not sure i'm missing something or it's a bug.

name: Rsync Deployments

on: [push]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: rsync deployments
      uses: burnett01/[email protected]
      with:
        switches: -avzr --delete
        path: ./*
        remote_path: public/github
        remote_host: ${{ secrets.HOST }}
        remote_port: ${{ secrets.PORT_STAGING }}
        remote_user: ${{ secrets.USERNAME }}
        remote_key: ${{ secrets.PRIVATE_KEY }}

Thanks.

Permission denied

image

I tried pushing to the server locally, and it worked, but failed on Actions.

Unable to negotiate with *** port ***: no matching host key type found.

I run the following action but give the error below:

  • name: rsync deployments
    uses: burnett01/[email protected]
    with:
    switches: -avzr --delete
    path: ./dist/ssr/
    remote_path: ${{ vars.HOST_PATH }}
    remote_host: ${{ secrets.SSH_HOST }}
    remote_port: ${{ secrets.SSH_PORT }}
    remote_user: ${{ secrets.SSH_USER }}
    remote_key: ${{ secrets.SSH_KEY }}

Identity added: (stdin) ((stdin))
Unable to negotiate with *** port ***: no matching host key type found. Their offer: ssh-rsa,ssh-dss
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(231) [sender=3.2.7]

FYI I'm able to connect via terminal from my local machine:
The successful cmd is:
ssh user@ip -pXXXXX

Error when sync

Hi im been using this action for a while, but now i'm having this issue with burnett01/[email protected].
When trying to sync files i got this error
rsync: mkdir "/***/2087:***" failed: No such file or directory (2)

rsync error: error in file IO (code 11) at main.c(664) [Receiver=3.1.3]
rsync: [sender] write error: Broken pipe (32)

I don't know why rsync is adding /***/2087: to the destination path.
Please advice
Thanks

Provide a list of files to the `src`

I would like to do an automatic rsync but only to the files changes on my last commit.
AFAIK, rsync supports this but I am not sure if the action does or how to do it.

Using bash/git, I can get a list of changed files and would like to use them as my input path making sure only those files are rsync-ed.

An example would be something like this:

jobs:
  changed-files:
    name: Changed files
    runs-on: ubuntu-latest
    # Map a step output to a job output
    outputs:
      all: ${{ steps.changes.outputs.all}}
    steps:
        # Make sure we have some code to diff.
      - name: Checkout repository
        uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Get changed files
        id: changes
        # Set outputs using the command.
        run: |
          echo "::set-output name=all::$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | xargs)"

  deploy:
    - name: Deploy to server
      id: deploy
      uses: burnett01/[email protected]
      with:
        switches: -avzr --delete
        path: '${{needs.changed-files.outputs.all}}'
        remote_path: ${{ secrets.DEPLOY_PATH }}
        remote_host: ${{ secrets.DEPLOY_HOST }}
        remote_port: ${{ secrets.DEPLOY_PORT }}
        remote_user: ${{ secrets.DEPLOY_USER }}
        remote_key: ${{ secrets.DEPLOY_KEY }}

Job doesn't fail if SSH Key Passphrase is wrong

Recently when I configured a new deploy workflow, I accidentally entered a wrong SSH Key Passphrase.

When the rsync deployment job was running, it was running and running forever. No files was uploaded. No errors was shown. I couldn't figure out why it was not working. I had to terminate the job manually, and the logs showed no error.

After a while I realized that I had entered a wrong Passphrase. After correcting this, the next deployment was working correctly.

So, it seems that if the Passphrase is wrong, the action does not abort or shows any error messages. It just keeps running until I manually abort.

I don't know if this is possible for you to handle in your action or not. Maybe it is a limitation in Rsync. But I just wanted to let you know.

Thanks for a great action!

Suggested additions to readme

Thanks for your work, I have a few minor suggestions that may help others when evaluating your action:

  • Document that path is relative to the github workspace. This means that only sub-paths of the workspace may be uploaded.
  • Document that the action can only run on amd64 hosts. arm build hosts cannot use this action.

(GitTea) No files are copied

Hello,

Job is executed but nothing happens 0 file is copied, could anybody help me with this issue ?
thanks in advance!

image

`name: Deployment
run-name: ${{ gitea.actor }} is testing out Gitea Actions ๐Ÿš€
on: [push]

jobs:
Explore-Gitea-Actions:
runs-on: ubuntu-latest
steps:
- name: Install rsync
run: |
apt-get -y update && apt-get -y install rsync

  - name: Check out repository code
    uses: actions/checkout@v3
    with:
      token: '${{ secrets.token }}'

  - name: List all files
    run: |
      ls -l
      pwd

  # https://github.com/Burnett01/rsync-deployments
  - name: ๐Ÿ“‚ Sync files
    uses: https://github.com/Burnett01/[email protected]
    with:
      switches: -avzr --delete --exclude=".git" --exclude=".github" --checksum
      path: /
      remote_path: /var/www/*****/test/
      remote_host: ****
      remote_port: ****
      remote_user: ****
      remote_key: ${{ secrets.SSH_KEY }}

`

Operation timed out

I don't know this timed out error is because of my setting or not.
Can you debug this error? Thank you.

Run burnett01/[email protected]
  with:
    switches: -avzr --delete
    path: build
    remote_path: ~/destination_folder
    remote_host: ***
    remote_user: ***
    remote_key: ***
    remote_port: 22
/usr/bin/docker run --name f884207d073a61d684487fa950f04f0cb87393_af9ec1 --label f88420 --workdir /github/workspace --rm -e INPUT_SWITCHES -e INPUT_PATH -e INPUT_REMOTE_PATH -e INPUT_REMOTE_HOST -e INPUT_REMOTE_USER -e INPUT_REMOTE_KEY -e INPUT_REMOTE_KEY_PASS -e INPUT_RSH -e INPUT_REMOTE_PORT -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_RUN_ATTEMPT -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e RUNNER_OS -e RUNNER_NAME -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/{project}/{folder}":"/github/workspace" f88420:7d073a61d684487fa950f04f0cb87393
Identity added: (stdin) (***)
ssh: connect to host *** port 22: Operation timed out
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(228) [sender=3.2.3]

Can I authenticate SSH using password?

Is it possible to use password on SSH auth instead of a certificate? My provider doesn't allow publickey auth because home directories are only mounted on login.

Syntax error in command?

I am using the following simple configuration straight from the book.

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
     ...
      - name: rsync deployment
        uses: burnett01/[email protected]
        with:
          switches: -avzr -vvv
          path: site
          remote_host: ${{ secrets.DEPLOY_HOST }}
          remote_user: ${{ secrets.DEPLOY_USER }}
          remote_path: ${{ secrets.DEPLOY_REMOTE_PATH }}
          remote_key: ${{ secrets.DEPLOY_KEY_PRIVATE }}

The action fails and I get the feeling there's a syntax somewhere in the generated command. Why else would rsync dump the help output to the console?

Identity added: (stdin) (***@s104.server.hostpoint.internal)
cmd=ssh -o StrictHostKeyChecking=no -p 22  machine=*** user=*** path=***
cmd[0]=ssh cmd[1]=-o cmd[2]=StrictHostKeyChecking=no cmd[3]=-p cmd[4]=22 cmd[5]=-l cmd[6]=*** cmd[7]=*** cmd[8]=rsync cmd[9]=--server cmd[10]=-vvvvlogDtprze.iLsfxCIvu cmd[11]=. cmd[12]=*** 
opening connection using: ssh -o StrictHostKeyChecking=no -p 22 -l *** *** rsync --server -vvvvlogDtprze.iLsfxCIvu . ***  (13 args)
msg checking charset: UTF-8
Warning: Permanently added '***' (ED25519) to the list of known hosts.
rsync  version 3.2.5  protocol version 31
Copyright (C) 1996-2022 by Andrew Tridgell, Wayne Davison, and others.
Web site: https://rsync.samba.org/
Capabilities:
    64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,
    socketpairs, symlinks, symtimes, hardlinks, hardlink-specials,
    hardlink-symlinks, IPv6, atimes, batchfiles, inplace, append, ACLs,
    xattrs, optional protect-args, iconv, no prealloc, stop-at, no crtimes
Optimizations:
    no SIMD-roll, no asm-roll, openssl-crypto, no asm-MD5
Checksum list:
    xxh128 xxh3 xxh64 (xxhash) md5 md4 none
Compress list:
    zstd lz4 zlibx zlib none

rsync comes with ABSOLUTELY NO WARRANTY.  This is free software, and you
are welcome to redistribute it under certain conditions.  See the GNU
General Public Licence for details.

rsync is a file transfer program capable of efficient remote update
via a fast differencing algorithm.

Usage: rsync [OPTION]... SRC [SRC]... DEST
  or   rsync [OPTION]... SRC [SRC]... [USER@]HOST:DEST
  or   rsync [OPTION]... SRC [SRC]... [USER@]HOST::DEST
  or   rsync [OPTION]... SRC [SRC]... rsync://[USER@]HOST[:PORT]/DEST
  or   rsync [OPTION]... [USER@]HOST:SRC [DEST]
  or   rsync [OPTION]... [USER@]HOST::SRC [DEST]
  or   rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]
The ':' usages connect via remote shell, while '::' & 'rsync://' usages connect
to an rsync daemon, and require SRC or DEST to start with a module name.

Options
--verbose, -v            increase verbosity
...
---

Use "rsync --daemon --help" to see the daemon-mode command-line options.
Please see the rsync(1) and rsyncd.conf(5) manpages for full documentation.
See https://rsync.samba.org/ for updates, bug reports, and answers
rsync error: syntax or usage error (code 1) at main.c(1754) [client=3.2.5]
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(228) [sender=3.2.4]
[sender] _exit_cleanup(code=12, file=io.c, line=228): entered
[sender] _exit_cleanup(code=12, file=io.c, line=228): about to call exit(12)

If I run rsync manually on macOS using the same secrets as configured on GitHub then all is well: rsync -avzr -e 'ssh -i ~/.ssh/my-private-key' site DEPLOY_USER@DEPLOY_HOST:DEPLOY_REMOTE_PATH.

I am more than just a little confused.

Permission Denied

Hi,

I have been getting the following error

rsync: mkdir "/var/www/html/beta_ia_site_uk" failed: Permission denied (13)

Been trying to trouble shoot but not sure what it could be

Screenshot 2022-03-26 at 11 15 57 am

Permission denied, please try again

image

I already try but always has above error
I config my private Key in settings -> secrets -> DEPLOY_KEY
example:

-----BEGIN RSA PRIVATE KEY-----
MIIJKAIBAAKCAgEA2ouTbQ/7omz4fy31QKj1y0pyK34f3UmArZKPVfKkupoWrLIz
....
-----END RSA PRIVATE KEY-----

and my yml is

name: Node CI

on:
  push:
    branchs:
      - master

jobs:
  build:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [12.x]

    steps:
      - uses: actions/checkout@v1
      - name: rsync deployments
        uses: burnett01/[email protected]
        with:
          switches: -avzr --delete
          path: ./web
          remote_path: /root/www
          remote_host: 23.91.96.81
          remote_user: root
          remote_key: ${{ secrets.DEPLOY_KEY }}

rsync: mkdir "/var/www/html" failed

logs

Identity added: (stdin) ((stdin))
Warning: Permanently added '***' (ECDSA) to the list of known hosts.
sending incremental file list
rsync: mkdir "/var/www/html" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at main.c(657) [Receiver=3.1.2]

rsync cannot create dir recursion. like mkdir -p.
so, maybe we can create dir before rsync.

rsync filter or exclude to account for .gitignore

This is not an issue, but a rather a request.

Your action works perfectly for our deployment flow, but we would want to retain the --delete flag so the contents of our repo stay an exact copy of what's been deployed to the server.

Since the remote_path will contain files and folders that cannot be deleted, the --delete flag is kind of harsh. We were thinking of a way that the rsync --filter or --exclude can take our .gitignore file contents into account.

There's a popular thread on StackOverflow, here: https://stackoverflow.com/questions/13713101/rsync-exclude-according-to-gitignore-hgignore-svnignore-like-filter-c, but usually our .gitignore file contains some lines that are not recognized by rsync, for example:

/themes/*
!/themes/theme-x
/themes/theme-x/gulp/.sass-cache

What are your thoughts on this?

Thanks a lot!

// T

Permission denied

Hey i have this error

Error loading key "(stdin)": invalid format
Warning: Permanently added '[myhost.fr]:***' (ED25519) to the list of known hosts.
Permission denied, please try again.
Permission denied, please try again.
***@myhost.fr: Permission denied (password,publickey).
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(228) [sender=3.2.4]

my workflow

name: SFTPP

on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v3
        with:
          ref: ${{ github.sha }}

      - name: rsync deployments
        uses: burnett01/[email protected]
        with:
          switches: -rlgoDzvc -i --delete
          path: ${{ secrets.LOCAL_FOLDER }}
          remote_path: ${{ secrets.REMOTE_FOLDER }}
          remote_host: ${{ secrets.SFTP_HOST }}
          remote_port: ${{ secrets.SFTP_PORT }}
          remote_user: ${{ secrets.SFTP_USER }}
          remote_key: ${{ secrets.SSH_KEY }}

Passphrase step

Hi, is there an example of private key authentication including a passphrase?

I'm blocked in the action with

entering the passphrase for (stdin):

I can't find an input option such as remote_passphrase for passing to the stdin the password

Thank you!

kex_exchange_identification: Connection closed by remote host

When I try to run this action, I get the error "kex_exchange_identification: Connection closed by remote host". Here's the whole output:

1 Run burnett01/[email protected]
2  with:
3     switches: -avzr --delete --exclude="" --include="" --filter=""
4     path: public/
5     remote_path: ***
6     remote_host: ***
7     remote_port: ***
8     remote_user: ***
9     remote_key: ***
10  
11 /usr/bin/docker run --name ea425bcb56b50298c342b0929f776e40d8f642_be5fc2 --label ea425b --workdir 
   โ€ฆ
12 Identity added: (stdin) ((stdin))
13 kex_exchange_identification: Connection closed by remote host
14 Connection closed by X.X.X.X port ***
15 rsync: connection unexpectedly closed (0 bytes received so far) [sender]
16 rsync error: unexplained error (code 255) at io.c(228) [sender=3.2.4]

I believe line 12 means I have the remote key set up correctly. Previously I was getting errors there because I wasn't using the private key. I'm deploying to a shared host at Hostrocket. I can ssh in to my account and I've made sure the ssh key I generated is in ~/.ssh. Do you have any ideas as to why I might be getting this error?

I receive rsync: connection unexpectedly closed (0 bytes received so far) [sender] when using the library

I provide the private key and the user of the remote ec2 machine to which want to send my files. The instance is being created successfully providing its DNS as output, but when this step runs it fails as below

ssh: connect to host ec2-7-100-132-4.compute-1.amazonaws.com port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.3]
    - name: 'Deploy to New Instance'
      uses: burnett01/[email protected]
      with:
        switches: -avzr --delete
        path: ./api
        remote_path: /home/${{ secrets.INSTANCE_USER }}/server
        remote_host: ${{ steps.terraform-output.outputs.stdout }}
        remote_user: ${{ secrets.INSTANCE_USER }}
        remote_key: ${{ secrets.INSTANCE_PRIVATE_KEY }}

The problem is that when I rerun the same workflow it runs correctly, but not the first time the instance is created. It has to fail for the first time. Any ideas what might be the problem?

Rsync missing

This is my current action:

name: DEPLOY
on:
  push:
    branches:
    - deploy-test

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: rsync deployments
      uses: burnett01/[email protected]
      with:
        switches: -avzr --delete
        path: wp-content/
        remote_path: ${{ secrets.DEPLOY_PATH }}
        remote_host: ${{ secrets.DEPLOY_HOST }}
        remote_user: ${{ secrets.DEPLOY_USER }}
        remote_key: ${{ secrets.DEPLOY_KEY }}

And this is the action output:

Identity added: (stdin) ((stdin))
Warning: Permanently added '***' (ED25519) to the list of known hosts.
bash: line 1: rsync: command not found
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code [12](https://github.com/craftedbygc/cosmos/actions/runs/5222055422/jobs/9427078356#step:4:13)) at io.c(231) [sender=3.2.7]

SSH Key protected by a passphrase?

Hello,

If my SSH key is protected by a passphrase, is there any way to have the action enter that passphrase when the key is used?

Enter passphrase for (stdin): Warning: Permanently added '[<myhost.com>]:yy,[xxx.xxx.xxx.xxx]:yy' (RSA) to the list of known hosts.

Thanks!
Ian

Passing an empty Github Action variable to `remote_path` circumvents validation and targets the root `/` directory

As the title says, I accidentally passed an empty variable to remote_path (I wrote ${{ env.REMOTE_PATH }} instead of ${{ vars.REMOTE_PATH }}). I was expecting this action to throw an error if I had mistyped, but the action actually ran and โ€“ you know the rest. I basically nuked the root directory of the remote server, since I also passed the --delete flag.

A more fool proof validation of the required input variables would be appreciated.

Files excluded in `.gitignore` files?

I'm currently building a workflow using self-hosted runners for a Laravel application to automatically:

  1. Run npm run build on a self hosted actions runner, populating ./public/* folders.
  2. Sync ./public/* from the runner to /var/www/public/* on the web server using this rsync action.

The issue at the moment is that the build output is not being transferred to the web server.

To go back a bit - to make this work, I added a .gitignore file to each folder in ./public/*. This is because the server pulls the latest changes via Git, which would create conflicts if the build output were included in source control.
This keeps the structure of the public directory in source control, but not the files. When a build succeeds, those files are "rsync-ed" to the server.

A strange thing is that the .gitignore files are being copied to the web server, just not the files that would be ignored.

Verification that runner has the build output

# start a shell on the self hosted runner
$ docker-compose exec github-runner bash 

# open the source directory
$ cd /tmp/runner/work/project-name/project-name/

# open the public folder
$ cd public

# list everything inside - `mix-manifest.json` is present, asserting the runner has created the build output successfully.
$ ls -lah

total 44K
drwxr-xr-x  7 root root 4.0K Sep 24 21:52 .
drwxr-xr-x 15 root root 4.0K Sep 24 21:51 ..
drwxr-xr-x  6 root root 4.0K Sep 24 21:50 css
-rw-r--r--  1 root root    0 Sep 24 18:29 favicon.ico
drwxr-xr-x  3 root root 4.0K Sep 24 21:52 fonts
-rw-r--r--  1 root root  698 Sep 24 18:29 .htaccess
drwxr-xr-x  3 root root 4.0K Sep 24 21:52 images
-rw-r--r--  1 root root 1.8K Sep 24 18:29 index.php
drwxr-xr-x  6 root root 4.0K Sep 24 18:29 js
-rw-r--r--  1 root root 3.5K Sep 24 21:52 mix-manifest.json   <---------------
-rw-r--r--  1 root root   24 Sep 24 18:29 robots.txt
drwxr-xr-x  4 root root 4.0K Sep 24 18:29 vendor                    

rsync output

I am expecting to see mix-manifest.json in this output.

/usr/bin/docker run 
    --name c3f2612037611bedbc4af49af158a513e1d677_8278ef 
    --label c3f261 
    --workdir /github/workspace 
    --rm 
    -e NVMRC 
    -e INPUT_SWITCHES 
    -e INPUT_PATH 
    -e INPUT_REMOTE_PATH 
    -e INPUT_REMOTE_HOST 
    -e INPUT_REMOTE_USER 
    -e INPUT_REMOTE_KEY 
    -e INPUT_RSH 
    -e INPUT_REMOTE_PORT 
    -e INPUT_REMOTE_KEY_PASS 
    -e HOME 
    -e GITHUB_JOB 
    -e GITHUB_REF 
    -e GITHUB_SHA 
    -e GITHUB_REPOSITORY 
    -e GITHUB_REPOSITORY_OWNER 
    -e GITHUB_RUN_ID 
    -e GITHUB_RUN_NUMBER 
    -e GITHUB_RETENTION_DAYS 
    -e GITHUB_RUN_ATTEMPT 
    -e GITHUB_ACTOR 
    -e GITHUB_WORKFLOW 
    -e GITHUB_HEAD_REF 
    -e GITHUB_BASE_REF 
    -e GITHUB_EVENT_NAME 
    -e GITHUB_SERVER_URL 
    -e GITHUB_API_URL 
    -e GITHUB_GRAPHQL_URL 
    -e GITHUB_WORKSPACE 
    -e GITHUB_ACTION 
    -e GITHUB_EVENT_PATH 
    -e GITHUB_ACTION_REPOSITORY 
    -e GITHUB_ACTION_REF 
    -e GITHUB_PATH 
    -e GITHUB_ENV 
    -e RUNNER_OS 
    -e RUNNER_NAME 
    -e RUNNER_TOOL_CACHE 
    -e RUNNER_TEMP 
    -e RUNNER_WORKSPACE 
    -e ACTIONS_RUNTIME_URL 
    -e ACTIONS_RUNTIME_TOKEN 
    -e ACTIONS_CACHE_URL 
    -e GITHUB_ACTIONS=true 
    -e CI=true 
    -v "/var/run/docker.sock":"/var/run/docker.sock" 
    -v "/tmp/runner/work/_temp/_github_home":"/github/home" 
    -v "/tmp/runner/work/_temp/_github_workflow":"/github/workflow" 
    -v "/tmp/runner/work/_temp/_runner_file_commands":"/github/file_commands" 
    -v "/tmp/runner/work/project-name/project-name":"/github/workspace" 
    c3f261:2037611bedbc4af49af158a513e1d677

Identity added: (stdin) (project_deploy)
Warning: Permanently added '***' (ED25519) to the list of known hosts.
sending incremental file list
./
.htaccess
favicon.ico
index.php
robots.txt
deleting css/marketing/.gitignore
deleting images/.gitignore
css/app-a/
css/app-a/.gitignore
css/app-b/
css/app-b/.gitignore
css/app-c/
css/app-c/.gitignore
css/marketing/
fonts/
fonts/.gitignore
images/
js/app-a/
js/app-a/.gitignore
js/app-b/
js/app-b/.gitignore
js/app-c/
js/app-c/.gitignore
js/marketing/
js/marketing/.gitignore

sent 2,562 bytes  received 18,609 bytes  8,468.40 bytes/sec
total size is 3,247,432  speedup is 153.39

Run with rsh option fails

I'm using this workflow configuration, which is working fine until I add the line with the remote shell commend:

    - name: Push Build files to testing environment
      uses: burnett01/[email protected]
      with:
        switches: -avzr --delete --exclude={'.git*','node_modules','.editorconfig','.env.*'}
        rsh: uptime # <-- this line causes the action to fail
        path: /
        remote_path: ${{ secrets.DEPLOY_PATH_DEV }}
        remote_host: ${{ secrets.DEPLOY_HOST }}
        remote_port: ${{ secrets.DEPLOY_PORT }}
        remote_user: ${{ secrets.DEPLOY_USER }}
        remote_key: ${{ secrets.DEPLOY_SSH_KEY }}
        remote_key_pass: ${{ secrets.DEPLOY_SSH_PHRASE }}

I get the following error:

ssh: Could not resolve hostname uptime: Name does not resolve

image

Am I doing something wrong here? Is this option not supposed to provide the possibility to run remote shell commands after deployment? I also tried with single quotes 'uptime', but it fails the same.

Thanks for any help on this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.