mirror of
https://github.com/appleboy/scp-action.git
synced 2024-11-23 00:36:10 +08:00
ci: add automated deployment for changed files (#105)
- Add a new job `changes` to the `ci.yml` file - Copy changed files to a server in the `changes` job - Add a YAML code block to the `README.md` file fix https://github.com/appleboy/scp-action/issues/73
This commit is contained in:
parent
43abfa778d
commit
6cd4f0cace
24
.github/workflows/ci.yml
vendored
24
.github/workflows/ci.yml
vendored
@ -113,3 +113,27 @@ jobs:
|
|||||||
port: ${{ secrets.PORT }}
|
port: ${{ secrets.PORT }}
|
||||||
source: distfiles/*
|
source: distfiles/*
|
||||||
target: test
|
target: test
|
||||||
|
|
||||||
|
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: ./
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.HOST }}
|
||||||
|
username: ${{ secrets.USERNAME }}
|
||||||
|
key: ${{ secrets.KEY }}
|
||||||
|
port: ${{ secrets.PORT }}
|
||||||
|
source: ${{ steps.changed-files.outputs.all_changed_files }}
|
||||||
|
target: test
|
||||||
|
28
README.md
28
README.md
@ -251,6 +251,34 @@ Remove the specified number of leading path elements:
|
|||||||
strip_components: 1
|
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:
|
Old target structure:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
@ -1 +1,2 @@
|
|||||||
foo
|
foo
|
||||||
|
foobar
|
||||||
|
@ -1 +1,2 @@
|
|||||||
bar
|
bar
|
||||||
|
foobar
|
||||||
|
@ -1 +1,3 @@
|
|||||||
c
|
c
|
||||||
|
foobar
|
||||||
|
test1234
|
||||||
|
@ -1 +1,3 @@
|
|||||||
d
|
d
|
||||||
|
foobar
|
||||||
|
foobar
|
||||||
|
Loading…
Reference in New Issue
Block a user