From b4f32c8242dc141467824b4fab230d5655750c40 Mon Sep 17 00:00:00 2001 From: Milan Kaneria Date: Fri, 1 Oct 2021 08:01:41 +0530 Subject: [PATCH] Features and code improvements - Modified files are now added to artifacts - Removed continue/reput option from FTP --- README.md | 6 ++++-- action.yml | 12 +++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7562486..14bf277 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ jobs: | ftp-options | no | | Additional arguments for FTP client | | ftp-mirror-options | no | | Additional arguments for mirroring | | webhook | no | | Send webhook event notifications | -| artifacts | no | false | Upload logs to artifacts (true, false) | +| artifacts | no | false | Upload logs/files to artifacts (true, false) | | debug | no | false | Enable debug information (true, false) | ### Notes @@ -145,13 +145,15 @@ jobs: "revision": "da39a3ee5e6b4b0d3255bfef95601890afd80709" } ``` -- Enabling `artifacts` will upload transfer log to artifacts +- Enabling `artifacts` will upload transfer log and modified files to artifacts + - Modified files are only added for delta file synchronization - Enabling `debug` option will output useful context, inputs, configuration file contents and transfer logs to help debug each step - It is strongly recommended to use [Encrypted Secrets](https://docs.github.com/en/actions/reference/encrypted-secrets) to store sensitive data like passwords and private keys ## Planned features - [x] Add transfer log to artifacts +- [x] Add modified files to artifacts - [ ] Add steps logging to file - [ ] Add steps log to artifacts - [x] Trigger webhook at start and end of step runs diff --git a/action.yml b/action.yml index c73e7f2..3622e4e 100644 --- a/action.yml +++ b/action.yml @@ -312,6 +312,10 @@ runs: if git cat-file -t ${git_previous_commit} &>/dev/null; then git diff --name-only --diff-filter=ACMRT ${git_previous_commit}..${{github.sha}} | grep --ignore-case --invert-match "^\.git.*" > ~/files_to_upload && echo "File created: ~/files_to_upload" && cat ~/files_to_upload && show_hr git diff --name-only --diff-filter=D ${git_previous_commit}..${{github.sha}} | grep --ignore-case --invert-match "^\.git.*" > ~/files_to_delete && echo "File created: ~/files_to_delete" && cat ~/files_to_delete && show_hr + + if [ "${{inputs.artifacts}}" == "true" ]; then + echo "Copy transfer artifacts" && mkdir ~/transfer_files && rsync --verbose --files-from=$HOME/files_to_upload . ~/transfer_files/ + fi else echo "::warning::Invalid base commit for delta synchronization: ${git_previous_commit}. Please ignore if this is an initial commit or newly created branch." fi @@ -340,7 +344,7 @@ runs: rm -f \"${remote_path_slash}.deploy-running\"" else ${proxy_cmd} lftp -c "put -O \"${remote_path_unslash}\" .deploy-running - mput -c -d -O \"${remote_path_unslash}\" .deploy-revision $(awk 'ORS=" " { print "\"" $0 "\"" }' ~/files_to_upload) + mput -d -O \"${remote_path_unslash}\" .deploy-revision $(awk 'ORS=" " { print "\"" $0 "\"" }' ~/files_to_upload) rm -f \"${remote_path_slash}.deploy-check\" $(awk 'ORS=" " { print "\"${remote_path_slash}" $0 "\"" }' ~/files_to_delete) rm -f \"${remote_path_slash}.deploy-running\"" fi @@ -367,6 +371,8 @@ runs: - name: "Upload artifacts" uses: actions/upload-artifact@v2 with: - name: "transfer_log" - path: '~/transfer_log.txt' + name: "transfer_artifacts" + path: | + ~/transfer_log.txt + ~/transfer_files if-no-files-found: ignore