Skip to content

Commit

Permalink
General code updates
Browse files Browse the repository at this point in the history
- Added artifacts support to upload logs
- Added planned features to readme
  • Loading branch information
milanmk committed Sep 2, 2021
1 parent 5104d81 commit d10d37b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 11 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ jobs:
| ssh-options | no | | Additional arguments for SSH client |
| ftp-options | no | | Additional arguments for FTP client |
| ftp-mirror-options | no | | Additional arguments for mirroring |
| artifacts | no | false | Upload logs to artifacts (true, false) |
| debug | no | false | Enable debug information (true, false) |

### Notes
Expand All @@ -110,4 +111,12 @@ jobs:
- Does not delete files on remote host
- Default glob exclude pattern is `.git*/`
- For `ftp-options` and `ftp-mirror-options` command arguments please refer to [LFTP manual](https://lftp.yar.ru/lftp-man.html)
- Enabling `artifacts` will upload transfer log to artifacts
- Enabling `debug` option will output useful context, inputs, configuration file contents and transfer logs to help debug each step

## Planned features

- [x] Add transfer log to artifacts
- [ ] Add steps logging to file
- [ ] Add steps log to artifacts
- [ ] Trigger webhook at start and end of step runs
42 changes: 31 additions & 11 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ inputs:
ftp-mirror-options:
description: "Additional command arguments for mirroring (lftp)"
required: false
artifacts:
description: "Upload logs to artifacts"
required: false
default: false
debug:
description: "Enable debug information (true, false)"
required: false
Expand All @@ -78,7 +82,9 @@ inputs:
runs:
using: "composite"
steps:
- run: |
- name: "Initialization"
shell: bash
run: |
echo "::group::Initialization"
printf '%.s_' {1..50} > ~/hr && echo "" >> ~/hr
Expand Down Expand Up @@ -131,8 +137,9 @@ runs:
echo "::endgroup::"
exit 0
- name: "Debug"
shell: bash
- run: |
run: |
if [ "${{ inputs.debug }}" == "true" ]; then
echo "::group::Debug"
Expand All @@ -146,8 +153,9 @@ runs:
fi
exit 0
- name: "Install packages"
shell: bash
- run: |
run: |
echo "::group::Install packages"
apt_install=""
Expand All @@ -163,8 +171,9 @@ runs:
echo "::endgroup::"
exit 0
- name: "Configurations"
shell: bash
- run: |
run: |
echo "::group::Configurations"
config_ssh=~/.ssh/config
Expand Down Expand Up @@ -206,7 +215,7 @@ runs:
set ftp:ssl-protect-data true
set ftp:sync-mode false
set log:enabled/xfer true
set log:file/xfer ~/.transfer_log
set log:file/xfer ~/transfer_log.txt
set log:show-time/xfer false
set mirror:overwrite true
set mirror:parallel-transfer-count 3
Expand All @@ -231,8 +240,9 @@ runs:
echo "::endgroup::"
exit 0
- name: "Setup proxy"
shell: bash
- run: |
run: |
if [ "${{ env.input_proxy }}" == "true" ]; then
echo "::group::Setup proxy"
Expand All @@ -252,8 +262,9 @@ runs:
fi
exit 0
- name: "Prepare files"
shell: bash
- run: |
run: |
echo "::group::Prepare files"
echo "Event: ${{ github.event_name }}
Expand Down Expand Up @@ -301,8 +312,9 @@ runs:
echo "::endgroup::"
exit 0
- name: "Transfer files"
shell: bash
- run: |
run: |
echo "::group::Transfer files"
echo "Protocol: ${{ inputs.remote-protocol }}
Expand All @@ -327,20 +339,28 @@ runs:
rm -f \"${{ env.remote_path_slash }}.deploy-running\""
fi
[ -f ~/.transfer_log ] && cat ~/.transfer_log
[ -f ~/transfer_log.txt ] && cat ~/transfer_log.txt
echo "::endgroup::"
exit 0
- name: "Cleanup"
shell: bash
- run: |
run: |
echo "::group::Cleanup"
[ "${{ env.input_proxy }}" == "true" ] && sudo pkill ssh
rm --force --verbose ~/.netrc ~/proxy_private_key ~/ssh_private_key
[ "${{ inputs.artifacts }}" != "true" ] && rm --force --verbose ~/transfer_log.txt
echo "::endgroup::"
exit 0
shell: bash
- name: "Upload artifacts"
uses: actions/upload-artifact@v2
with:
name: "transfer_log"
path: '~/transfer_log.txt'
if-no-files-found: ignore

0 comments on commit d10d37b

Please sign in to comment.