Archive and Upload to FTP #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Archive and Upload to FTP | |
on: workflow_dispatch | |
# push: | |
# branches: | |
# - master | |
jobs: | |
archive_and_upload: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Archive folders | |
run: | | |
# Define folders to archive | |
folder_list=( | |
"AspNet4/Mvc/AdhocReporting" | |
"AspNetCore/Razor-Mvc/Razor.AdHocReporting" | |
) | |
# Export folders array so it's accessible in the next step | |
echo "folder_list=${folder_list[*]}" >> $GITHUB_ENV | |
# Archive each folder | |
for folder in "${folder_list[@]}"; do | |
zip_file_name=$(echo "$folder" | sed 's/\//-/g').zip | |
zip -r "$zip_file_name" "$folder" | |
echo $zip_file_name | |
done | |
- name: Upload to FTP | |
env: | |
FTP_HOST: ${{ secrets.FTP_HOST }} | |
FTP_USERNAME: ${{ secrets.FTP_USERNAME }} | |
FTP_PASSWORD: ${{ secrets.FTP_PASSWORD }} | |
run: | | |
# Convert the folders string back to an array | |
IFS=' ' read -r -a folder_list <<< "$folder_list" | |
for folder in "${folder_list[@]}"; do | |
zip_file_name=$(echo "$folder" | sed 's/\//-/g').zip | |
echo $zip_file_name | |
curl -T "$zip_file_name" --ftp-create-dirs -u "$FTP_USERNAME:$FTP_PASSWORD" "ftp://$FTP_HOST/cdn.korzh.com/dot-net-samples/$zip_file_name" | |
echo "ftp://$FTP_HOST/cdn.korzh.com/dot-net-samples/$zip_file_name" | |
done |