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:
Bo-Yi Wu 2023-04-09 18:10:17 +08:00 committed by GitHub
parent 43abfa778d
commit 6cd4f0cace
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 58 additions and 0 deletions

View File

@ -113,3 +113,27 @@ jobs:
port: ${{ secrets.PORT }}
source: distfiles/*
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

View File

@ -251,6 +251,34 @@ Remove the specified number of leading path elements:
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

View File

@ -1 +1,2 @@
foo
foobar

View File

@ -1 +1,2 @@
bar
foobar

View File

@ -1 +1,3 @@
c
foobar
test1234

View File

@ -1 +1,3 @@
d
foobar
foobar