diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 56839fd..211cf45 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -113,3 +113,32 @@ 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 + + - name: List all changed files + run: | + for file in ${{ steps.changed-files.outputs.all_changed_files }}; do + echo "$file was changed" + done + + - name: copy file to server + uses: ./ + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + key: ${{ secrets.KEY }} + port: ${{ secrets.PORT }} + source: ${{ join(steps.changed-files.outputs.all_changed_files, ',') }} + target: test diff --git a/README.md b/README.md index 55b1d3d..a5a884c 100644 --- a/README.md +++ b/README.md @@ -251,6 +251,39 @@ 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 + + - name: List all changed files + run: | + for file in ${{ steps.changed-files.outputs.all_changed_files }}; do + echo "$file was changed" + done + + - name: copy file to server + uses: ./ + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + key: ${{ secrets.KEY }} + port: ${{ secrets.PORT }} + source: ${{ join(steps.changed-files.outputs.all_changed_files, ',') }} + target: test +``` + Old target structure: ```sh 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