Bringing in my own version of srueda99s scp-action for my own use :)
This commit is contained in:
parent
1e6222dfd8
commit
3bd16a1efd
11
scp-action/Dockerfile
Normal file
11
scp-action/Dockerfile
Normal file
@ -0,0 +1,11 @@
|
||||
# Runs on Alpine container, latest version.
|
||||
FROM alpine
|
||||
# Copy the content to the container.
|
||||
COPY . /
|
||||
# Grant executable permission on the script.
|
||||
RUN ["chmod", "+x", "/entrypoint.sh"]
|
||||
# Update the apk and download openssh
|
||||
RUN ["apk", "update"]
|
||||
RUN ["apk", "add", "git", "openssh"]
|
||||
# Runs the script.
|
||||
ENTRYPOINT [ "/entrypoint.sh" ]
|
21
scp-action/LICENSE
Normal file
21
scp-action/LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022 Sebastian Rueda
|
||||
|
||||
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.
|
78
scp-action/README.md
Normal file
78
scp-action/README.md
Normal file
@ -0,0 +1,78 @@
|
||||
# SCP ACTION
|
||||
***By `SRUEDA99`***
|
||||
|
||||
Forked by `shockrah` with minor improvement in the `entrypoint.sh`
|
||||
file for my own personal use.
|
||||
|
||||
## Overview
|
||||
This action to copy the files from your repository to a remote server using **SCP** (Secure Copy Protocol).
|
||||
|
||||
## How to use it
|
||||
You must give:
|
||||
- The `host` which is the public address or the public DNS of the destination server.
|
||||
- The `username` that will be used in the remote server.
|
||||
- The `destination` folder, where the content will be copied.
|
||||
- The `password` for the user or the private `key` in case the connection is based on SSH keys.
|
||||
|
||||
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 `passphrase` if necessary.
|
||||
|
||||
**IMPORTANT**
|
||||
```
|
||||
Use Github secrets to give these parameters.
|
||||
```
|
||||
|
||||
## 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**
|
||||
```
|
||||
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 }}
|
||||
```
|
||||
|
||||
**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!_
|
39
scp-action/action.yml
Normal file
39
scp-action/action.yml
Normal file
@ -0,0 +1,39 @@
|
||||
name: 'SCP Deployment'
|
||||
description: 'Copies the files from your repository to a remote host using SCP'
|
||||
author: 'Sebastian Rueda'
|
||||
inputs:
|
||||
# $1
|
||||
port:
|
||||
description: 'Port for SCP'
|
||||
default: 22
|
||||
# $2
|
||||
host:
|
||||
description: 'IP Address or DNS of your target host'
|
||||
# $3
|
||||
origin:
|
||||
description: 'Source route folder'
|
||||
default: "./*"
|
||||
# $4
|
||||
destination:
|
||||
description: 'Destination route folder'
|
||||
# $5
|
||||
username:
|
||||
description: 'User for remote connection'
|
||||
# $6
|
||||
password:
|
||||
description: 'Password for the user'
|
||||
# $7
|
||||
key:
|
||||
description: 'Private SSH key'
|
||||
# $8
|
||||
passphrase:
|
||||
description: 'Passphrase for SSH key'
|
||||
outputs:
|
||||
time:
|
||||
description: 'Returns the time when the script ran'
|
||||
runs:
|
||||
using: 'docker'
|
||||
image: 'Dockerfile'
|
||||
branding:
|
||||
icon: 'send'
|
||||
color: 'black'
|
21
scp-action/entrypoint.sh
Executable file
21
scp-action/entrypoint.sh
Executable file
@ -0,0 +1,21 @@
|
||||
#!/bin/sh -l
|
||||
|
||||
# Checking if the key input is not empty
|
||||
if [[ "$INPUT_KEY" ]]; then
|
||||
# If it is not empty, it uses the key for the SCP
|
||||
echo -e "${INPUT_KEY}" > key # Creates a file with the key content
|
||||
chmod 400 key # Set the key as Read-Only
|
||||
echo "Trying SCP process with SSH key"
|
||||
# Runs the SCP command
|
||||
scp -P $INPUT_PORT -o StrictHostKeyChecking=no -i key $INPUT_ORIGIN "$INPUT_USERNAME"@"$INPUT_HOST":"$INPUT_DESTINATION"
|
||||
else
|
||||
# If the keyis empty, it uses the password for the SCP
|
||||
echo "Trying SCP process with password"
|
||||
# Runs the SCP command
|
||||
sshpass -p $INPUT_PASSWORD scp -P $INPUT_PORT -o StrictHostKeyChecking=no -r $INPUT_ORIGIN "$INPUT_USERNAME"@"$INPUT_HOST":"$INPUT_DESTINATION"
|
||||
fi
|
||||
time=$(date)
|
||||
echo "-----------------------------"
|
||||
echo "| Files copied successfully |"
|
||||
echo "-----------------------------"
|
||||
echo "::set-output name=time::$time"
|
Loading…
Reference in New Issue
Block a user