Compare commits
28 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
196ea3f88f | ||
|
034b0ad00c | ||
|
95e250284b | ||
|
a593d18cb8 | ||
|
2e28e2ddc9 | ||
|
f8189f0fbf | ||
|
722ddfc32b | ||
|
e506e72e83 | ||
|
bd7b71696a | ||
|
b1b9ed628c | ||
|
72fe6fa2ca | ||
|
f1b7ce641c | ||
|
722d935a90 | ||
|
6fd371aeaf | ||
|
5138976c70 | ||
|
d322577e98 | ||
|
c0a815a115 | ||
|
afd2e26f9f | ||
|
2ef3f5e459 | ||
|
f0de4fea6f | ||
|
03e93ae863 | ||
|
bffdab6759 | ||
|
e22c039905 | ||
|
44284b60e4 | ||
|
b154adaf5c | ||
|
a6224ab4f0 | ||
|
1a31789cbc | ||
|
74e3e1df58 |
65
.github/main.workflow
vendored
65
.github/main.workflow
vendored
@@ -1,65 +0,0 @@
|
||||
workflow "Copy File Via SSH" {
|
||||
on = "push"
|
||||
resolves = [
|
||||
"Copy file via ssh password",
|
||||
"Copy file via ssh key",
|
||||
"Add source in args",
|
||||
"Add secret in args",
|
||||
]
|
||||
}
|
||||
|
||||
action "Copy file via ssh password" {
|
||||
uses = "appleboy/scp-action@master"
|
||||
env = {
|
||||
SOURCE = "tests/a.txt,tests/b.txt"
|
||||
TARGET = "/home/actions/test"
|
||||
}
|
||||
secrets = [
|
||||
"HOST",
|
||||
"USERNAME",
|
||||
"PASSWORD",
|
||||
]
|
||||
}
|
||||
|
||||
action "Copy file via ssh key" {
|
||||
uses = "appleboy/scp-action@master"
|
||||
env = {
|
||||
SOURCE = "tests/a.txt,tests/b.txt"
|
||||
TARGET = "/home/actions/test"
|
||||
}
|
||||
secrets = [
|
||||
"HOST",
|
||||
"USERNAME",
|
||||
"KEY",
|
||||
]
|
||||
}
|
||||
|
||||
action "Add source in args" {
|
||||
uses = "appleboy/scp-action@master"
|
||||
env = {
|
||||
TARGET = "/home/actions/test1234"
|
||||
}
|
||||
secrets = [
|
||||
"HOST",
|
||||
"USERNAME",
|
||||
"KEY",
|
||||
]
|
||||
args = ["--source", "tests/a.txt", "--source", "tests/b.txt"]
|
||||
}
|
||||
|
||||
action "Add secret in args" {
|
||||
uses = "appleboy/scp-action@master"
|
||||
env = {
|
||||
TARGET = "/home/actions/test1234"
|
||||
}
|
||||
secrets = [
|
||||
"HOST",
|
||||
"TEST_USERNAME",
|
||||
"KEY",
|
||||
]
|
||||
args = [
|
||||
"--username", "$TEST_USERNAME",
|
||||
"--source", "tests/a.txt",
|
||||
"--source", "tests/b.txt",
|
||||
]
|
||||
}
|
39
.github/workflows/ci.yml
vendored
Normal file
39
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
name: scp files
|
||||
on: [push]
|
||||
jobs:
|
||||
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: copy file via ssh password
|
||||
uses: appleboy/scp-action@master
|
||||
with:
|
||||
host: ${{ secrets.HOST }}
|
||||
username: ${{ secrets.USERNAME }}
|
||||
password: ${{ secrets.PASSWORD }}
|
||||
port: ${{ secrets.PORT }}
|
||||
source: "tests/a.txt,tests/b.txt"
|
||||
target: "test"
|
||||
|
||||
- name: copy file via ssh key
|
||||
uses: appleboy/scp-action@master
|
||||
with:
|
||||
host: ${{ secrets.HOST }}
|
||||
username: ${{ secrets.USERNAME }}
|
||||
key: ${{ secrets.KEY }}
|
||||
port: ${{ secrets.PORT }}
|
||||
source: "tests/a.txt,tests/b.txt"
|
||||
target: "test"
|
||||
|
||||
- name: remove the specified number of leading path elements
|
||||
uses: appleboy/scp-action@master
|
||||
with:
|
||||
host: ${{ secrets.HOST }}
|
||||
username: ${{ secrets.USERNAME }}
|
||||
key: ${{ secrets.KEY }}
|
||||
port: ${{ secrets.PORT }}
|
||||
source: "tests/a.txt,tests/b.txt"
|
||||
target: "foobar"
|
||||
strip_components: 1
|
13
Dockerfile
13
Dockerfile
@@ -1,15 +1,4 @@
|
||||
FROM appleboy/drone-scp:1.5.1-linux-amd64
|
||||
|
||||
# Github labels
|
||||
LABEL "com.github.actions.name"="SCP Files"
|
||||
LABEL "com.github.actions.description"="Copy files and artifacts via SSH"
|
||||
LABEL "com.github.actions.icon"="copy"
|
||||
LABEL "com.github.actions.color"="gray-dark"
|
||||
|
||||
LABEL "repository"="https://github.com/appleboy/scp-action"
|
||||
LABEL "homepage"="https://github.com/appleboy"
|
||||
LABEL "maintainer"="Bo-Yi Wu <appleboy.tw@gmail.com>"
|
||||
LABEL "version"="0.0.1"
|
||||
FROM appleboy/drone-scp:1.5.3-linux-amd64
|
||||
|
||||
ADD entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
187
README.md
187
README.md
@@ -1,97 +1,144 @@
|
||||
# 🚀 SCP for GitHub Actions
|
||||
|
||||
[GitHub Action](https://developer.github.com/actions/) for copying files and artifacts via SSH.
|
||||
[GitHub Action](https://github.com/features/actions) for copying files and artifacts via SSH.
|
||||
|
||||
<img src="./images/copy-multiple-file.png">
|
||||

|
||||
|
||||
[](https://github.com/appleboy/scp-action/actions)
|
||||
|
||||
## Usage
|
||||
|
||||
copy files and artifacts via SSH as blow.
|
||||
|
||||
```
|
||||
action "Copy multiple file" {
|
||||
uses = "appleboy/scp-action@master"
|
||||
env = {
|
||||
HOST = "example.com"
|
||||
USERNAME = "foo"
|
||||
PASSWORD = "bar"
|
||||
PORT = "22"
|
||||
SOURCE = "tests/a.txt,tests/b.txt"
|
||||
TARGET = "/home/foo/test"
|
||||
}
|
||||
secrets = [
|
||||
"PASSWORD",
|
||||
]
|
||||
}
|
||||
```yaml
|
||||
name: scp files
|
||||
on: [push]
|
||||
jobs:
|
||||
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: copy file via ssh password
|
||||
uses: appleboy/scp-action@master
|
||||
with:
|
||||
host: ${{ secrets.HOST }}
|
||||
username: ${{ secrets.USERNAME }}
|
||||
password: ${{ secrets.PASSWORD }}
|
||||
port: ${{ secrets.PORT }}
|
||||
source: "tests/a.txt,tests/b.txt"
|
||||
target: "test"
|
||||
```
|
||||
|
||||
## Environment variables
|
||||
## Input variables
|
||||
|
||||
* HOST - ssh server host
|
||||
* PORT - ssh server port
|
||||
* USERNAME - ssh server username
|
||||
* PASSWORD - ssh server password
|
||||
* KEY - ssh server private key
|
||||
* TARGET - target folder
|
||||
* SOURCE - scp file list
|
||||
see the [action.yml](./action.yml) file for more detail imformation.
|
||||
|
||||
* host - scp remote host
|
||||
* port - scp remote port
|
||||
* username - scp username
|
||||
* password - scp password
|
||||
* timeout - timeout for ssh to remote host, default is `30s`
|
||||
* command_timeout - timeout for scp command, default is `1m`
|
||||
* key - content of ssh private key. ex raw content of ~/.ssh/id_rsa
|
||||
* key_path - path of ssh private key
|
||||
* target - target path on the server
|
||||
* source - scp file list
|
||||
* rm - remove target folder before upload data
|
||||
* strip_components - remove the specified number of leading path elements.
|
||||
* overwrite - use `--overwrite` flag with tar
|
||||
* tar_tmp_path - temporary path for tar file on the dest host
|
||||
|
||||
### Example
|
||||
|
||||
Copy file via ssh password
|
||||
|
||||
```
|
||||
action "Copy multiple file" {
|
||||
uses = "appleboy/scp-action@master"
|
||||
env = {
|
||||
HOST = "example.com"
|
||||
USERNAME = "foo"
|
||||
PORT = "22"
|
||||
SOURCE = "tests/a.txt,tests/b.txt"
|
||||
TARGET = "/home/foo/test"
|
||||
}
|
||||
secrets = [
|
||||
"PASSWORD",
|
||||
]
|
||||
}
|
||||
```yaml
|
||||
- name: copy file via ssh password
|
||||
uses: appleboy/scp-action@master
|
||||
with:
|
||||
host: example.com
|
||||
username: foo
|
||||
password: bar
|
||||
port: 22
|
||||
source: "tests/a.txt,tests/b.txt"
|
||||
target: "test"
|
||||
```
|
||||
|
||||
Copy file via ssh key
|
||||
|
||||
```
|
||||
action "Copy file via ssh key" {
|
||||
uses = "appleboy/scp-action@master"
|
||||
env = {
|
||||
HOST = "example.com"
|
||||
USERNAME = "foo"
|
||||
PORT = "22"
|
||||
SOURCE = "tests/c.txt,tests/d.txt"
|
||||
TARGET = "/home/actions/test"
|
||||
}
|
||||
secrets = [
|
||||
"KEY",
|
||||
]
|
||||
}
|
||||
```yaml
|
||||
- name: copy file via ssh key
|
||||
uses: appleboy/scp-action@master
|
||||
env:
|
||||
HOST: ${{ secrets.HOST }}
|
||||
USERNAME: ${{ secrets.USERNAME }}
|
||||
PORT: ${{ secrets.PORT }}
|
||||
KEY: ${{ secrets.KEY }}
|
||||
with:
|
||||
source: "tests/a.txt,tests/b.txt"
|
||||
target: "test"
|
||||
```
|
||||
|
||||
Example configuration for ignore list:
|
||||
|
||||
```
|
||||
action "reqular expression list" {
|
||||
uses = "appleboy/scp-action@master"
|
||||
env = {
|
||||
HOST = "example.com"
|
||||
USERNAME = "foo"
|
||||
PORT = "22"
|
||||
SOURCE = "tests/*.txt,!tests/a.txt"
|
||||
TARGET = "/home/actions/test"
|
||||
}
|
||||
secrets = [
|
||||
"KEY",
|
||||
]
|
||||
}
|
||||
```yaml
|
||||
- name: copy file via ssh key
|
||||
uses: appleboy/scp-action@master
|
||||
env:
|
||||
HOST: ${{ secrets.HOST }}
|
||||
USERNAME: ${{ secrets.USERNAME }}
|
||||
PORT: ${{ secrets.PORT }}
|
||||
KEY: ${{ secrets.KEY }}
|
||||
with:
|
||||
source: "tests/*.txt,!tests/a.txt"
|
||||
target: "test"
|
||||
```
|
||||
|
||||
## Secrets
|
||||
Example configuration for multiple server
|
||||
|
||||
* `PASSWORD` - ssh server password
|
||||
* `KEY` - ssh server private key
|
||||
```diff
|
||||
- name: copy file via ssh password
|
||||
uses: appleboy/scp-action@master
|
||||
with:
|
||||
- host: "example.com"
|
||||
+ host: "foo.com,bar.com"
|
||||
username: foo
|
||||
password: bar
|
||||
port: 22
|
||||
source: "tests/a.txt,tests/b.txt"
|
||||
target: "test"
|
||||
```
|
||||
|
||||
remove the specified number of leading path elements
|
||||
|
||||
```yaml
|
||||
- name: remove the specified number of leading path elements
|
||||
uses: appleboy/scp-action@master
|
||||
with:
|
||||
host: ${{ secrets.HOST }}
|
||||
username: ${{ secrets.USERNAME }}
|
||||
key: ${{ secrets.KEY }}
|
||||
port: ${{ secrets.PORT }}
|
||||
source: "tests/a.txt,tests/b.txt"
|
||||
target: "foobar"
|
||||
strip_components: 1
|
||||
```
|
||||
|
||||
old target structure:
|
||||
|
||||
```sh
|
||||
foobar
|
||||
└── tests
|
||||
├── a.txt
|
||||
└── b.txt
|
||||
```
|
||||
|
||||
new target structure:
|
||||
|
||||
```sh
|
||||
foobar
|
||||
├── a.txt
|
||||
└── b.txt
|
||||
```
|
||||
|
44
action.yml
Normal file
44
action.yml
Normal file
@@ -0,0 +1,44 @@
|
||||
name: 'SCP Command to Transfer Files'
|
||||
description: 'How to Use SCP Command to Transfer Files/Folders in Linux'
|
||||
author: 'Bo-Yi Wu'
|
||||
inputs:
|
||||
host:
|
||||
description: 'scp remote host'
|
||||
port:
|
||||
description: 'scp remote port'
|
||||
default: 22
|
||||
username:
|
||||
description: 'scp username'
|
||||
password:
|
||||
description: 'scp password'
|
||||
timeout:
|
||||
description: 'timeout for ssh to remote host'
|
||||
default: "30s"
|
||||
command_timeout:
|
||||
description: 'timeout for scp command'
|
||||
default: "1m"
|
||||
key:
|
||||
description: 'content of ssh private key. ex raw content of ~/.ssh/id_rsa'
|
||||
key_path:
|
||||
description: 'path of ssh private key'
|
||||
target:
|
||||
description: 'target path on the server'
|
||||
source:
|
||||
description: 'scp file list'
|
||||
rm:
|
||||
description: 'remove target folder before upload data'
|
||||
strip_components:
|
||||
description: 'remove the specified number of leading path elements'
|
||||
default: 0
|
||||
overwrite:
|
||||
description: 'use `--overwrite` flag with tar'
|
||||
default: false
|
||||
tar_tmp_path:
|
||||
description: 'temporary path for tar file on the dest host'
|
||||
runs:
|
||||
using: 'docker'
|
||||
image: 'Dockerfile'
|
||||
|
||||
branding:
|
||||
icon: 'copy'
|
||||
color: 'gray-dark'
|
@@ -4,4 +4,6 @@ set -eu
|
||||
|
||||
export GITHUB="true"
|
||||
|
||||
[ -n "$INPUT_STRIP_COMPONENTS" ] && export INPUT_STRIP_COMPONENTS=$((INPUT_STRIP_COMPONENTS + 0))
|
||||
|
||||
sh -c "/bin/drone-scp $*"
|
||||
|
Reference in New Issue
Block a user