22 Commits

Author SHA1 Message Date
Bo-Yi Wu
722ddfc32b chore: upgrade to drone-scp:1.5.2
Some checks failed
scp files / Build (push) Failing after 7s
2019-09-28 12:55:25 +08:00
Bo-Yi Wu
e506e72e83 remove debug message
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2019-09-28 12:45:17 +08:00
Bo-Yi Wu
bd7b71696a debug
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2019-09-28 12:43:06 +08:00
Bo-Yi Wu
b1b9ed628c docs: update default value 2019-09-28 12:41:21 +08:00
Bo-Yi Wu
72fe6fa2ca add default value
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2019-09-28 12:39:28 +08:00
Bo-Yi Wu
f1b7ce641c update INPUT_STRIP_COMPONENTS
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2019-09-28 12:37:22 +08:00
Bo-Yi Wu
722d935a90 update INPUT_STRIP_COMPONENTS
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2019-09-28 12:34:38 +08:00
Bo-Yi Wu
6fd371aeaf docs: add example 2019-09-28 12:26:40 +08:00
Bo-Yi Wu
5138976c70 docs: add badge 2019-09-28 12:17:08 +08:00
Bo-Yi Wu
d322577e98 docs: update readme 2019-09-28 12:16:21 +08:00
Bo-Yi Wu
c0a815a115 docs: update readme. 2019-09-28 12:13:03 +08:00
Bo-Yi Wu
afd2e26f9f chore: copy file via ssh key 2019-09-28 12:01:18 +08:00
Bo-Yi Wu
2ef3f5e459 chore: check timeout variable 2019-09-28 11:40:28 +08:00
Bo-Yi Wu
f0de4fea6f chore: add default timeout 2019-09-28 11:37:34 +08:00
Bo-Yi Wu
03e93ae863 chore: update target 2019-09-28 11:32:50 +08:00
Bo-Yi Wu
bffdab6759 chore: update 2019-09-28 11:23:50 +08:00
Bo-Yi Wu
e22c039905 chore: checkout source code. 2019-09-28 11:15:01 +08:00
Bo-Yi Wu
44284b60e4 chore: add timeout flag 2019-09-28 11:10:11 +08:00
Bo-Yi Wu
b154adaf5c chore: copy file via ssh password 2019-09-28 10:54:49 +08:00
Bo-Yi Wu
a6224ab4f0 chore: add github actions config 2019-09-28 10:42:13 +08:00
Bo-Yi Wu
1a31789cbc chore: rename the worflow file 2019-09-28 10:32:00 +08:00
Bo-Yi Wu
74e3e1df58 docs: add args command helper. 2019-05-12 10:25:37 +08:00
6 changed files with 185 additions and 146 deletions

65
.github/main.workflow vendored
View File

@@ -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
View 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

View File

@@ -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.2-linux-amd64
ADD entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

174
README.md
View File

@@ -2,96 +2,132 @@
[GitHub Action](https://developer.github.com/actions/) for copying files and artifacts via SSH.
<img src="./images/copy-multiple-file.png">
![ssh key](./images/copy-multiple-file.png)
[![Actions Status](https://github.com/appleboy/scp-action/workflows/scp%20files/badge.svg)](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: 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
* command_timeout - timeout for scp command
* 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.
### 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
```

38
action.yml Normal file
View File

@@ -0,0 +1,38 @@
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'
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
runs:
using: 'docker'
image: 'Dockerfile'
branding:
icon: 'copy'
color: 'gray-dark'

View File

@@ -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 $*"