Zip and Publish Subfolders #38
Workflow file for this run
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: Zip and Publish Subfolders | |
on: | |
release: | |
types: [published] | |
jobs: | |
zip-and-publish: | |
runs-on: ubuntu-latest | |
outputs: | |
files: ${{ steps.list_zip_files.outputs.files }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Create zip files for each subfolder | |
run: | | |
for dir in $(find . -mindepth 1 -maxdepth 1 -type d); do | |
zip -r "${dir##*/}.zip" "$dir" | |
done | |
- name: List zip files | |
id: list_zip_files | |
run: | | |
files=$(ls *.zip | jq -R . | jq -s . | tr -d '\n' | tr -d ' ') | |
echo "files=$files" >> $GITHUB_OUTPUT | |
shell: bash | |
- name: Debug output | |
run: echo "$files" | |
shell: bash | |
upload-artifacts: | |
needs: zip-and-publish | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
file: ${{ fromJson(needs.zip-and-publish.outputs.files) }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Debug output | |
run: | | |
# Check if the correct number of arguments is provided | |
if [ "$#" -ne 1 ]; then | |
echo "Usage: $0 <file_path>" | |
exit 1 | |
fi | |
# Assign the first argument to a variable | |
file_path="$1" | |
# Check if the file exists | |
if [ -e "$file_path" ]; then | |
echo "The file '$file_path' exists." | |
else | |
echo "The file '$file_path' does not exist." | |
fi | |
shell: bash | |
- name: Upload artifact | |
uses: actions/upload-release-asset@v1 | |
with: | |
upload_url: ${{ github.event.release.upload_url }} | |
asset_path: ${{ matrix.file }} | |
asset_name: ${{ matrix.file }} | |
asset_content_type: application/zip |