Rebranding the project to be rsync since thats what were doing now
This commit is contained in:
parent
5ff3f80e6f
commit
68c61830b6
@ -6,5 +6,4 @@ RUN chmod +x /entrypoint.sh && \
|
|||||||
apk update && \
|
apk update && \
|
||||||
apk add git openssh rsync
|
apk add git openssh rsync
|
||||||
|
|
||||||
|
|
||||||
ENTRYPOINT [ "/entrypoint.sh" ]
|
ENTRYPOINT [ "/entrypoint.sh" ]
|
||||||
|
4
LICENSE
4
LICENSE
@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2022 Sebastian Rueda
|
Copyright (c) 2024 temper.tv
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
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
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
|
88
README.md
88
README.md
@ -1,78 +1,42 @@
|
|||||||
# SCP ACTION
|
# Rsync Action
|
||||||
|
|
||||||
***By `temper`***
|
***By `temper`***
|
||||||
|
|
||||||
Original by `SRUEDA99` however I've made this work for hugo projects
|
Based off `SRUEDA99` scp-action due to the simplicity of that project
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
This action to copy the files from your repository to a remote server using **SCP** (Secure Copy Protocol).
|
|
||||||
|
|
||||||
## How to use it
|
This Github action uses Rsync to copy files over ssh
|
||||||
You must give:
|
|
||||||
- The `host` which is the public address or the public DNS of the destination server.
|
## Input Parameters
|
||||||
- The `username` that will be used in the remote server.
|
|
||||||
- The `destination` folder, where the content will be copied.
|
Required Parameters
|
||||||
- The `password` for the user or the private `key` in case the connection is based on SSH keys.
|
|
||||||
|
* `host` IP/Hostname of target.
|
||||||
|
* `username` on the target IP/host that is used to copy files to.
|
||||||
|
* `source` - Source file or folder to copy
|
||||||
|
* `destination` - the folder where the content will be copied.
|
||||||
|
* `key` - the private key used to secure the connection to the target.
|
||||||
|
|
||||||
|
Optional Parameters:
|
||||||
|
|
||||||
Optional:
|
|
||||||
- The `origin` folder is set by default as __"./*"__ but you can also specify it.
|
|
||||||
- The `port` is set as **22** by default, you can also specify another one.
|
- The `port` is set as **22** by default, you can also specify another one.
|
||||||
- The `passphrase` if necessary.
|
|
||||||
|
|
||||||
**IMPORTANT**
|
## Secrets
|
||||||
```
|
|
||||||
Use Github secrets to give these parameters.
|
It is recommended to pass all sensitive values through `secrets`
|
||||||
```
|
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
**With password**
|
|
||||||
```
|
|
||||||
name: copy using password
|
|
||||||
uses: srueda99/scp-action@v12
|
|
||||||
with:
|
|
||||||
port: 22
|
|
||||||
host: ${{ secrets.SERVER_ADDRESS }}
|
|
||||||
destination: "/home/${{ secrets.SERVER_USERNAME }}/"
|
|
||||||
username: ${{ secrets.SERVER_USERNAME }}
|
|
||||||
password: ${{ secrets.SERVER_PASSWORD }}
|
|
||||||
```
|
|
||||||
|
|
||||||
**With key**
|
```yaml
|
||||||
```
|
name: Copy single file
|
||||||
name: copy using key
|
uses: tempersama/rsync-action@1.4
|
||||||
uses: srueda99/scp-action@v12
|
|
||||||
with:
|
with:
|
||||||
port: 22
|
host: ${{ secrets.host }}
|
||||||
host: ${{ secrets.SERVER_ADDRESS }}
|
source: html/
|
||||||
destination: "/home/${{ secrets.SERVER_USERNAME }}/"
|
destination: /opt/nginx/website.com
|
||||||
username: ${{ secrets.SERVER_USERNAME }}
|
username: ${{ secrets.username }}
|
||||||
key: ${{ secrets.SERVER_KEY }}
|
key: ${{ secrets.SERVER_KEY }}
|
||||||
|
port: 2222
|
||||||
```
|
```
|
||||||
|
|
||||||
**With origin folder**
|
|
||||||
```
|
|
||||||
name: copy using password
|
|
||||||
uses: srueda99/scp-action@v12
|
|
||||||
with:
|
|
||||||
port: 22
|
|
||||||
host: ${{ secrets.SERVER_ADDRESS }}
|
|
||||||
origin: "./*"
|
|
||||||
destination: "/home/${{ secrets.SERVER_USERNAME }}/"
|
|
||||||
username: ${{ secrets.SERVER_USERNAME }}
|
|
||||||
password: ${{ secrets.SERVER_PASSWORD }}
|
|
||||||
```
|
|
||||||
|
|
||||||
**With passphrase**
|
|
||||||
```
|
|
||||||
name: copy using key
|
|
||||||
uses: srueda99/scp-action@v12
|
|
||||||
with:
|
|
||||||
port: 22
|
|
||||||
host: ${{ secrets.SERVER_ADDRESS }}
|
|
||||||
destination: "/home/${{ secrets.SERVER_USERNAME }}/"
|
|
||||||
username: ${{ secrets.SERVER_USERNAME }}
|
|
||||||
key: ${{ secrets.SERVER_KEY }}
|
|
||||||
passphrase: ${{ secrets.SERVER_PASSPHRASE }}
|
|
||||||
```
|
|
||||||
|
|
||||||
_Enjoy it!_
|
|
||||||
|
15
action.yml
15
action.yml
@ -1,5 +1,5 @@
|
|||||||
name: 'Recursive SCP Deployment'
|
name: 'Rsync Action'
|
||||||
description: 'Recusively copies the files from your repository to a remote host using SCP'
|
description: 'Copies the files from your repository to a remote host using rsync'
|
||||||
author: 'temper'
|
author: 'temper'
|
||||||
inputs:
|
inputs:
|
||||||
# $1
|
# $1
|
||||||
@ -10,7 +10,7 @@ inputs:
|
|||||||
host:
|
host:
|
||||||
description: 'IP Address or DNS of your target host'
|
description: 'IP Address or DNS of your target host'
|
||||||
# $3
|
# $3
|
||||||
origin:
|
source:
|
||||||
description: 'Source route folder'
|
description: 'Source route folder'
|
||||||
default: "./*"
|
default: "./*"
|
||||||
# $4
|
# $4
|
||||||
@ -19,18 +19,9 @@ inputs:
|
|||||||
# $5
|
# $5
|
||||||
username:
|
username:
|
||||||
description: 'User for remote connection'
|
description: 'User for remote connection'
|
||||||
# $6
|
|
||||||
password:
|
|
||||||
description: 'Password for the user'
|
|
||||||
# $7
|
# $7
|
||||||
key:
|
key:
|
||||||
description: 'Private SSH key'
|
description: 'Private SSH key'
|
||||||
# $8
|
|
||||||
passphrase:
|
|
||||||
description: 'Passphrase for SSH key'
|
|
||||||
outputs:
|
|
||||||
time:
|
|
||||||
description: 'Returns the time when the script ran'
|
|
||||||
runs:
|
runs:
|
||||||
using: 'docker'
|
using: 'docker'
|
||||||
image: 'Dockerfile'
|
image: 'Dockerfile'
|
||||||
|
@ -1,18 +1,24 @@
|
|||||||
#!/bin/sh -l
|
#!/bin/sh -l -e
|
||||||
|
|
||||||
set -e
|
# Quick checks for missing parameters
|
||||||
|
rc=0
|
||||||
|
empty() { echo ERROR: $1 is empty }
|
||||||
|
|
||||||
# Checking if the key input is not empty
|
[[ "$INPUT_HOST" ]] && empty host
|
||||||
if [[ "$INPUT_KEY" ]]; then
|
[[ "$INPUT_SOURCE" ]] && empty source
|
||||||
# If it is not empty, it uses the key for the rsync command
|
[[ "$INPUT_DESTINATION" ]] && empty destination
|
||||||
echo -e "${INPUT_KEY}" > key # Creates a file with the key content
|
[[ "$INPUT_USERNME" ]] && empty username
|
||||||
chmod 400 key # Set the key as Read-Only
|
[[ "$INPUT_KEY" ]] && empty key
|
||||||
|
|
||||||
rsync -a -v --stats -e "ssh -p $INPUT_PORT -o StrictHostKeyChecking=no -i key" \
|
|
||||||
"$INPUT_ORIGIN" \
|
|
||||||
"$INPUT_USERNAME"@"$INPUT_HOST":"$INPUT_DESTINATION"
|
echo -e "${INPUT_KEY}" > key
|
||||||
fi
|
chmod 400 key
|
||||||
time=$(date)
|
|
||||||
echo "-----------------------------"
|
# TODO: make sure we are not just blindly using StrictHostKeyChecking=no
|
||||||
echo "| Files copied successfully |"
|
rsync \
|
||||||
echo "-----------------------------"
|
-a -v \ --stats \
|
||||||
|
-e "ssh -o StrictHostKeyChecking=no -i key" \
|
||||||
|
--port $INPUT_PORT \
|
||||||
|
"$INPUT_SOURCE" \
|
||||||
|
"$INPUT_USERNAME"@"$INPUT_HOST":"$INPUT_DESTINATION"
|
||||||
|
Loading…
Reference in New Issue
Block a user