Archive and Upload to FTP #6
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: Set the folders list | |
id: folder_list | |
run: | | |
# Define folders to archive | |
folder_list=( | |
"AspNet4/Mvc/AdhocReporting" | |
"AspNetCore/Razor-Mvc/Razor.AdHocReporting" | |
) | |
echo "folder_list=$folder_list" >> "$GITHUB_ENV" | |
- name: Archive folders | |
run: | | |
echo "$folder_list" | |
# 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: | | |
echo "$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 | |
echo "Zip files uploaded" |