Archive and Upload to FTP #4
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 up FTP configuration | |
env: | |
FTP_HOST: ${{ secrets.FTP_HOST }} | |
FTP_USERNAME: ${{ secrets.FTP_USERNAME }} | |
FTP_PASSWORD: ${{ secrets.FTP_PASSWORD }} | |
run: | | |
echo "FTP configuration set" | |
- name: Archive folders | |
run: | | |
# Define folders to archive | |
echo $folders | |
folders=( | |
"AspNet4/Mvc/AdhocReporting" | |
"AspNetCore/Razor-Mvc/Razor.AdHocReporting" | |
) | |
# Archive each folder | |
for folder in "${folders[@]}"; do | |
zip_file_name=$(echo "$folder" | sed 's/\//-/g').zip | |
zip -r "$zip_file_name" "$folder" | |
echo $zip_file_name | |
done | |
echo "Folders compressed" | |
- name: Upload to FTP | |
run: | | |
echo $folders | |
for folder in "${folders[@]}"; 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" | |
- name: Complete | |
run: | | |
echo "Complete" | |