Initial commit
This commit is contained in:
commit
64ecb8fe3c
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2024 h7x4
|
||||||
|
|
||||||
|
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.
|
|
@ -0,0 +1,36 @@
|
||||||
|
# Rsync action
|
||||||
|
|
||||||
|
This action sends the contents of a directory to a remote server using [rsync][rsync].
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Basic usage:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- name: Transfer files
|
||||||
|
uses: https://git.pvv.ntnu.no/oysteikt/rsync-action@v1
|
||||||
|
with:
|
||||||
|
source: ./path/to/directory/
|
||||||
|
target: /path/at/remote/
|
||||||
|
username: username
|
||||||
|
host: hostname
|
||||||
|
ssh-key: ${{ secrets.SSH_KEY }}
|
||||||
|
```
|
||||||
|
|
||||||
|
Advanced usage:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- name: Transfer files
|
||||||
|
uses: https://git.pvv.ntnu.no/oysteikt/rsync-action@v1
|
||||||
|
with:
|
||||||
|
source: ./path/to/directory/
|
||||||
|
target: /path/at/remote/
|
||||||
|
username: username
|
||||||
|
host: hostname
|
||||||
|
port: 2222
|
||||||
|
ssh-key: ${{ secrets.SSH_KEY }}
|
||||||
|
args: -avz --mkpath --exclude 'node_modules' --delete
|
||||||
|
known-hosts-content: "[hostname]:2222 ssh-ed25519 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||||
|
```
|
||||||
|
|
||||||
|
[rsync]: https://rsync.samba.org/
|
|
@ -0,0 +1,91 @@
|
||||||
|
name: 'Rsync SSH transfer'
|
||||||
|
description: 'Transfer files to another location'
|
||||||
|
inputs:
|
||||||
|
username:
|
||||||
|
description: "Username to be used for login"
|
||||||
|
required: true
|
||||||
|
ssh-key:
|
||||||
|
description: "private SSH key to use for logging int"
|
||||||
|
required: false
|
||||||
|
host:
|
||||||
|
description: "Host to log in at"
|
||||||
|
required: true
|
||||||
|
port:
|
||||||
|
description: "Port to connect to"
|
||||||
|
required: true
|
||||||
|
default: "22"
|
||||||
|
known-host-content:
|
||||||
|
description: "Content to add to the known_hosts file, to verify the authenticity of the remote"
|
||||||
|
required: false
|
||||||
|
source:
|
||||||
|
description: "Which files to copy"
|
||||||
|
required: true
|
||||||
|
target:
|
||||||
|
description: "Where on the host to copy the files"
|
||||||
|
required: true
|
||||||
|
args:
|
||||||
|
description: "Command line args to pass to rsync"
|
||||||
|
required: true
|
||||||
|
default: "--archive --compression --verbose --mkpath"
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- name: Install rsync
|
||||||
|
run: |
|
||||||
|
if ! command -v apt-get &> /dev/null
|
||||||
|
then
|
||||||
|
echo "Only apt is supported"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if command -v rsync &> /dev/null
|
||||||
|
then
|
||||||
|
echo "rsync is already installed"
|
||||||
|
else
|
||||||
|
sudo apt-get install -y rsync
|
||||||
|
fi
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Create SSH directory
|
||||||
|
run: |
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Install SSH config
|
||||||
|
run: |
|
||||||
|
echo <<EOF > ~/.ssh/config
|
||||||
|
Host targethost
|
||||||
|
User ${{ inputs.username }}
|
||||||
|
HostName ${{ inputs.host }}
|
||||||
|
Port ${{ inputs.port }}
|
||||||
|
ForwardAgent no
|
||||||
|
ForwardX11 no
|
||||||
|
PasswordAuthentication no
|
||||||
|
EOF
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Install SSH known_hosts
|
||||||
|
run: |
|
||||||
|
echo "${{ inputs.known-host-content }}" > ~/.ssh/known_hosts
|
||||||
|
echo " StrictHostKeyChecking yes" >> ~/.ssh/config
|
||||||
|
shell: bash
|
||||||
|
if: ${{ inputs.known-host-content != null }}
|
||||||
|
|
||||||
|
- name: Disable SSH host key checking
|
||||||
|
run: |
|
||||||
|
echo " StrictHostKeyChecking no" >> ~/.ssh/config
|
||||||
|
shell: bash
|
||||||
|
if: ${{ inputs.known-host-content == null }}
|
||||||
|
|
||||||
|
|
||||||
|
- name: Install SSH key
|
||||||
|
run: |
|
||||||
|
echo "${{ inputs.ssh-key }}" > ~/.ssh/id_rsa
|
||||||
|
chmod 600 ~/.ssh/id_rsa
|
||||||
|
shell: bash
|
||||||
|
if: ${{ inputs.ssh-key != null }}
|
||||||
|
|
||||||
|
- name: Transfer files
|
||||||
|
run: rsync ${{ inputs.args }} "${{ inputs.source }}" "targethost:${{ inputs.target }}"
|
||||||
|
shell: bash
|
Loading…
Reference in New Issue