diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 56839fd..516a8ab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/README.md b/README.md index 55b1d3d..9692c1d 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/tests/a.txt b/tests/a.txt index 257cc56..4f6c252 100644 --- a/tests/a.txt +++ b/tests/a.txt @@ -1 +1,2 @@ foo +foobar diff --git a/tests/b.txt b/tests/b.txt index 5716ca5..c494264 100644 --- a/tests/b.txt +++ b/tests/b.txt @@ -1 +1,2 @@ bar +foobar diff --git a/tests/c.txt b/tests/c.txt index f2ad6c7..06cab46 100644 --- a/tests/c.txt +++ b/tests/c.txt @@ -1 +1,3 @@ c +foobar +test1234 diff --git a/tests/d.txt b/tests/d.txt index 4bcfe98..13a80d9 100644 --- a/tests/d.txt +++ b/tests/d.txt @@ -1 +1,3 @@ d +foobar +foobar