Compare commits
27 Commits
v0.1.4
...
9ba62064d2
Author | SHA1 | Date | |
---|---|---|---|
|
9ba62064d2 | ||
|
f314a5399e | ||
|
699fa1181c | ||
|
9f34cc3e55 | ||
|
917f8b81df | ||
|
78e7f475f3 | ||
|
dfde1f50eb | ||
|
35093a99f9 | ||
|
96947ea2bd | ||
|
aef31a66e3 | ||
|
950981a11d | ||
|
5878fc908f | ||
|
abb6d70bee | ||
|
b03ad1c124 | ||
|
d398e64fcf | ||
|
3710327b67 | ||
|
d47d818ab7 | ||
|
7435be3541 | ||
|
11da0c97f9 | ||
|
ec73feb854 | ||
|
cdeb36bbf9 | ||
|
c209399d24 | ||
|
952a6e3250 | ||
|
82ebdbe3ed | ||
|
2cd029d317 | ||
|
e0dbae8ff0 | ||
|
3e84ad0651 |
235
.github/workflows/ci.yml
vendored
235
.github/workflows/ci.yml
vendored
@@ -1,139 +1,150 @@
|
||||
name: scp files
|
||||
on: [push]
|
||||
jobs:
|
||||
|
||||
testing:
|
||||
name: test scp action
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: copy file via ssh password
|
||||
uses: ./
|
||||
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 password
|
||||
uses: ./
|
||||
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: ./
|
||||
with:
|
||||
host: ${{ secrets.HOST }}
|
||||
username: ${{ secrets.USERNAME }}
|
||||
key: ${{ secrets.KEY }}
|
||||
port: ${{ secrets.PORT }}
|
||||
source: "tests/a.txt,tests/b.txt"
|
||||
target: "test"
|
||||
- name: copy file via ssh key
|
||||
uses: ./
|
||||
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: ./
|
||||
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
|
||||
- name: remove the specified number of leading path elements
|
||||
uses: ./
|
||||
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
|
||||
|
||||
- name: ssh key with passphrase
|
||||
uses: ./
|
||||
with:
|
||||
host: ${{ secrets.HOST }}
|
||||
username: ${{ secrets.USERNAME }}
|
||||
key: ${{ secrets.SSH2 }}
|
||||
passphrase: ${{ secrets.PASSPHRASE }}
|
||||
port: ${{ secrets.PORT }}
|
||||
source: "tests/a.txt,tests/b.txt"
|
||||
target: "test"
|
||||
- name: ssh key with passphrase
|
||||
uses: ./
|
||||
with:
|
||||
host: ${{ secrets.HOST }}
|
||||
username: ${{ secrets.USERNAME }}
|
||||
key: ${{ secrets.SSH2 }}
|
||||
passphrase: ${{ secrets.PASSPHRASE }}
|
||||
port: ${{ secrets.PORT }}
|
||||
source: "tests/a.txt,tests/b.txt"
|
||||
target: "test"
|
||||
|
||||
- name: use insecure cipher
|
||||
uses: ./
|
||||
with:
|
||||
host: ${{ secrets.HOST }}
|
||||
username: ${{ secrets.USERNAME }}
|
||||
key: ${{ secrets.SSH2 }}
|
||||
passphrase: ${{ secrets.PASSPHRASE }}
|
||||
port: ${{ secrets.PORT }}
|
||||
source: "tests/a.txt,tests/b.txt"
|
||||
target: "test"
|
||||
use_insecure_cipher: true
|
||||
|
||||
- name: correct key but wrong password
|
||||
uses: appleboy/scp-action@7af00892de6f8397c5c3393cfb3b32ae7f91b94b
|
||||
with:
|
||||
host: ${{ secrets.HOST }}
|
||||
username: ${{ secrets.USERNAME }}
|
||||
key: ${{ secrets.KEY }}
|
||||
password: abcdefg
|
||||
port: ${{ secrets.PORT }}
|
||||
source: "tests/a.txt,tests/b.txt"
|
||||
target: "test"
|
||||
|
||||
- name: correct password but wrong key
|
||||
uses: appleboy/scp-action@7af00892de6f8397c5c3393cfb3b32ae7f91b94b
|
||||
with:
|
||||
host: ${{ secrets.HOST }}
|
||||
username: ${{ secrets.USERNAME }}
|
||||
key: abcdefg
|
||||
password: ${{ secrets.PASSWORD }}
|
||||
port: ${{ secrets.PORT }}
|
||||
source: "tests/a.txt,tests/b.txt"
|
||||
target: "test"
|
||||
- name: use insecure cipher
|
||||
uses: ./
|
||||
with:
|
||||
host: ${{ secrets.HOST }}
|
||||
username: ${{ secrets.USERNAME }}
|
||||
key: ${{ secrets.SSH2 }}
|
||||
passphrase: ${{ secrets.PASSPHRASE }}
|
||||
port: ${{ secrets.PORT }}
|
||||
source: "tests/a.txt,tests/b.txt"
|
||||
target: "test"
|
||||
use_insecure_cipher: true
|
||||
|
||||
deploy:
|
||||
name: deploy artifact
|
||||
name: test deploy artifact
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- run: echo hello > world.txt
|
||||
- run: echo hello > world.txt
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: my-artifact
|
||||
path: world.txt
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: my-artifact
|
||||
path: world.txt
|
||||
|
||||
- uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: my-artifact
|
||||
path: distfiles
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: my-artifact
|
||||
path: distfiles
|
||||
|
||||
- name: copy file to server
|
||||
uses: ./
|
||||
with:
|
||||
host: ${{ secrets.HOST }}
|
||||
username: ${{ secrets.USERNAME }}
|
||||
key: ${{ secrets.KEY }}
|
||||
port: ${{ secrets.PORT }}
|
||||
source: distfiles/*
|
||||
target: test
|
||||
- name: copy file to server
|
||||
uses: ./
|
||||
with:
|
||||
host: ${{ secrets.HOST }}
|
||||
username: ${{ secrets.USERNAME }}
|
||||
key: ${{ secrets.KEY }}
|
||||
port: ${{ secrets.PORT }}
|
||||
source: distfiles/*
|
||||
target: test
|
||||
|
||||
changes:
|
||||
name: test changed-files
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Get changed files
|
||||
id: changed-files
|
||||
uses: tj-actions/changed-files@v35
|
||||
with:
|
||||
since_last_remote_commit: true
|
||||
separator: ","
|
||||
- name: Get changed files
|
||||
id: changed-files
|
||||
uses: tj-actions/changed-files@v44
|
||||
with:
|
||||
since_last_remote_commit: true
|
||||
separator: ","
|
||||
|
||||
- name: copy file to server
|
||||
uses: ./
|
||||
with:
|
||||
host: ${{ secrets.HOST }}
|
||||
username: ${{ secrets.USERNAME }}
|
||||
key: ${{ secrets.KEY }}
|
||||
port: ${{ secrets.PORT }}
|
||||
source: ${{ steps.changed-files.outputs.all_changed_files }}
|
||||
target: test
|
||||
- name: copy file to server
|
||||
uses: ./
|
||||
with:
|
||||
host: ${{ secrets.HOST }}
|
||||
username: ${{ secrets.USERNAME }}
|
||||
key: ${{ secrets.KEY }}
|
||||
port: ${{ secrets.PORT }}
|
||||
source: ${{ steps.changed-files.outputs.all_changed_files }}
|
||||
target: test
|
||||
|
||||
target:
|
||||
name: test target folder
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: copy file to server
|
||||
uses: ./
|
||||
with:
|
||||
host: ${{ secrets.HOST }}
|
||||
username: ${{ secrets.USERNAME }}
|
||||
key: ${{ secrets.KEY }}
|
||||
port: ${{ secrets.PORT }}
|
||||
source: tests/a.txt,tests/b.txt
|
||||
target: foobar foobar 1234
|
||||
|
||||
multipleHost:
|
||||
name: test Multiple Host
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: copy file to server
|
||||
uses: ./
|
||||
with:
|
||||
host: ${{ secrets.HOST }}:${{ secrets.PORT }},${{ secrets.HOST }}:${{ secrets.PORT }}
|
||||
username: ${{ secrets.USERNAME }}
|
||||
key: ${{ secrets.KEY }}
|
||||
port: 1024
|
||||
source: tests/a.txt,tests/b.txt
|
||||
target: foobar
|
||||
|
@@ -1,5 +1,5 @@
|
||||
FROM ghcr.io/appleboy/drone-scp:1.6.7
|
||||
FROM ghcr.io/appleboy/drone-scp:1.6.14
|
||||
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
COPY entrypoint.sh /bin/entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["/bin/entrypoint.sh"]
|
||||
|
131
README.md
131
README.md
@@ -19,16 +19,16 @@ jobs:
|
||||
name: Build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- uses: actions/checkout@v4
|
||||
- name: copy file via ssh password
|
||||
uses: appleboy/scp-action@master
|
||||
uses: appleboy/scp-action@v0.1.7
|
||||
with:
|
||||
host: ${{ secrets.HOST }}
|
||||
username: ${{ secrets.USERNAME }}
|
||||
password: ${{ secrets.PASSWORD }}
|
||||
port: ${{ secrets.PORT }}
|
||||
source: "tests/a.txt,tests/b.txt"
|
||||
target: "test"
|
||||
target: your_server_target_folder_path
|
||||
```
|
||||
|
||||
## Input variables
|
||||
@@ -137,48 +137,48 @@ Copy file via a SSH password:
|
||||
|
||||
```yaml
|
||||
- name: copy file via ssh password
|
||||
uses: appleboy/scp-action@master
|
||||
uses: appleboy/scp-action@v0.1.7
|
||||
with:
|
||||
host: example.com
|
||||
username: foo
|
||||
password: bar
|
||||
port: 22
|
||||
source: "tests/a.txt,tests/b.txt"
|
||||
target: "test"
|
||||
target: your_server_target_folder_path
|
||||
```
|
||||
|
||||
Copy file via a SSH key:
|
||||
|
||||
```yaml
|
||||
- name: copy file via ssh key
|
||||
uses: appleboy/scp-action@master
|
||||
uses: appleboy/scp-action@v0.1.7
|
||||
with:
|
||||
host: ${{ secrets.HOST }}
|
||||
username: ${{ secrets.USERNAME }}
|
||||
port: ${{ secrets.PORT }}
|
||||
key: ${{ secrets.KEY }}
|
||||
source: "tests/a.txt,tests/b.txt"
|
||||
target: "test"
|
||||
target: your_server_target_folder_path
|
||||
```
|
||||
|
||||
Example configuration for ignore list:
|
||||
|
||||
```yaml
|
||||
- name: copy file via ssh key
|
||||
uses: appleboy/scp-action@master
|
||||
uses: appleboy/scp-action@v0.1.7
|
||||
with:
|
||||
host: ${{ secrets.HOST }}
|
||||
username: ${{ secrets.USERNAME }}
|
||||
port: ${{ secrets.PORT }}
|
||||
key: ${{ secrets.KEY }}
|
||||
source: "tests/*.txt,!tests/a.txt"
|
||||
target: "test"
|
||||
target: your_server_target_folder_path
|
||||
```
|
||||
|
||||
Example configuration for multiple servers:
|
||||
|
||||
```diff
|
||||
uses: appleboy/scp-action@master
|
||||
uses: appleboy/scp-action@v0.1.7
|
||||
with:
|
||||
- host: "example.com"
|
||||
+ host: "foo.com,bar.com"
|
||||
@@ -186,13 +186,13 @@ Example configuration for multiple servers:
|
||||
password: bar
|
||||
port: 22
|
||||
source: "tests/a.txt,tests/b.txt"
|
||||
target: "test"
|
||||
target: your_server_target_folder_path
|
||||
```
|
||||
|
||||
Example configuration for exclude custom files:
|
||||
|
||||
```yaml
|
||||
uses: appleboy/scp-action@master
|
||||
uses: appleboy/scp-action@v0.1.7
|
||||
with:
|
||||
host: "example.com"
|
||||
username: foo
|
||||
@@ -200,7 +200,7 @@ Example configuration for exclude custom files:
|
||||
port: 22
|
||||
- source: "tests/*.txt"
|
||||
+ source: "tests/*.txt,!tests/a.txt,!tests/b.txt"
|
||||
target: "test"
|
||||
target: your_server_target_folder_path
|
||||
```
|
||||
|
||||
Upload artifact files to remote server:
|
||||
@@ -211,74 +211,46 @@ Upload artifact files to remote server:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- run: echo hello > world.txt
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: my-artifact
|
||||
path: world.txt
|
||||
|
||||
- uses: actions/download-artifact@v2
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: my-artifact
|
||||
path: distfiles
|
||||
|
||||
- name: copy file to server
|
||||
uses: appleboy/scp-action@master
|
||||
uses: appleboy/scp-action@v0.1.7
|
||||
with:
|
||||
host: ${{ secrets.HOST }}
|
||||
username: ${{ secrets.USERNAME }}
|
||||
key: ${{ secrets.KEY }}
|
||||
port: ${{ secrets.PORT }}
|
||||
source: distfiles/*
|
||||
target: test
|
||||
target: your_server_target_folder_path
|
||||
```
|
||||
|
||||
Remove the specified number of leading path elements:
|
||||
|
||||
```yaml
|
||||
- name: remove the specified number of leading path elements
|
||||
uses: appleboy/scp-action@master
|
||||
uses: appleboy/scp-action@v0.1.7
|
||||
with:
|
||||
host: ${{ secrets.HOST }}
|
||||
username: ${{ secrets.USERNAME }}
|
||||
key: ${{ secrets.KEY }}
|
||||
port: ${{ secrets.PORT }}
|
||||
source: "tests/a.txt,tests/b.txt"
|
||||
target: "foobar"
|
||||
target: your_server_target_folder_path
|
||||
strip_components: 1
|
||||
```
|
||||
|
||||
Only copy files that are newer than the corresponding destination files:
|
||||
|
||||
```yaml
|
||||
changes:
|
||||
name: test changed-files
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Get changed files
|
||||
id: changed-files
|
||||
uses: tj-actions/changed-files@v35
|
||||
with:
|
||||
since_last_remote_commit: true
|
||||
separator: ","
|
||||
|
||||
- name: copy file to server
|
||||
uses: appleboy/scp-action@master
|
||||
with:
|
||||
host: ${{ secrets.HOST }}
|
||||
username: ${{ secrets.USERNAME }}
|
||||
key: ${{ secrets.KEY }}
|
||||
port: ${{ secrets.PORT }}
|
||||
source: ${{ steps.changed-files.outputs.all_changed_files }}
|
||||
target: test
|
||||
```
|
||||
|
||||
Old target structure:
|
||||
|
||||
```sh
|
||||
@@ -296,11 +268,39 @@ foobar
|
||||
└── b.txt
|
||||
```
|
||||
|
||||
Only copy files that are newer than the corresponding destination files:
|
||||
|
||||
```yaml
|
||||
changes:
|
||||
name: test changed-files
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Get changed files
|
||||
id: changed-files
|
||||
uses: tj-actions/changed-files@v35
|
||||
with:
|
||||
since_last_remote_commit: true
|
||||
separator: ","
|
||||
|
||||
- name: copy file to server
|
||||
uses: appleboy/scp-action@v0.1.7
|
||||
with:
|
||||
host: ${{ secrets.HOST }}
|
||||
username: ${{ secrets.USERNAME }}
|
||||
key: ${{ secrets.KEY }}
|
||||
port: ${{ secrets.PORT }}
|
||||
source: ${{ steps.changed-files.outputs.all_changed_files }}
|
||||
target: your_server_target_folder_path
|
||||
```
|
||||
|
||||
Protecting a Private Key. The purpose of the passphrase is usually to encrypt the private key. This makes the key file by itself useless to an attacker. It is not uncommon for files to leak from backups or decommissioned hardware, and hackers commonly exfiltrate files from compromised systems.
|
||||
|
||||
```diff
|
||||
- name: ssh key with passphrase
|
||||
uses: appleboy/scp-action@master
|
||||
uses: appleboy/scp-action@v0.1.7
|
||||
with:
|
||||
host: ${{ secrets.HOST }}
|
||||
username: ${{ secrets.USERNAME }}
|
||||
@@ -308,5 +308,36 @@ Protecting a Private Key. The purpose of the passphrase is usually to encrypt th
|
||||
+ passphrase: ${{ secrets.PASSPHRASE }}
|
||||
port: ${{ secrets.PORT }}
|
||||
source: "tests/a.txt,tests/b.txt"
|
||||
target: "test"
|
||||
target: your_server_target_folder_path
|
||||
```
|
||||
|
||||
When copying files from a Linux runner to a Windows server, you should:
|
||||
|
||||
1. Download git for Windows
|
||||
2. Change the default OpenSSH shell to git bach with the following powershell command.
|
||||
3. Set `tar_dereference` and `rm` variable to `true` in the YAML file
|
||||
4. Avoid putting the `port` value through a variable
|
||||
5. Convert the target path to a Unix path: `/c/path/to/target/`
|
||||
|
||||
Change the default OpenSSH shell to git bach with the following powershell command.
|
||||
|
||||
```powershell
|
||||
New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "$env:Programfiles\Git\bin\bash.exe" -PropertyType String -Force
|
||||
```
|
||||
|
||||
Convert the target path to a Unix path: `/c/path/to/target/`
|
||||
|
||||
```diff
|
||||
- name: Copy to Windows
|
||||
uses: appleboy/scp-action@v0.1.7
|
||||
with:
|
||||
host: ${{ secrets.HOST }}
|
||||
username: ${{ secrets.USERNAME }}
|
||||
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
port: 22
|
||||
source: 'your_source_path'
|
||||
- target: 'C:\path\to\target'
|
||||
+ target: '/c/path/to/target/'
|
||||
+ tar_dereference: true
|
||||
+ rm: true
|
||||
```
|
||||
|
Reference in New Issue
Block a user