Skip to content

Zip and Publish Subfolders #18

Zip and Publish Subfolders

Zip and Publish Subfolders #18

name: Zip and Publish Subfolders
on:
release:
types: [published]
jobs:
zip-and-publish:
runs-on: ubuntu-latest
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)
files_json=$(jq -n --arg files "$files" '{"files": $files | split(" ")}')
echo "$files_json" > files.json
echo "files=$files" >> $GITHUB_ENV
- name: Upload files.json
uses: actions/upload-artifact@v3
with:
name: files-json
path: files.json
upload-artifacts:
needs: zip-and-publish
runs-on: ubuntu-latest
strategy:
matrix:
file: ${{ fromJson(needs.zip-and-publish.outputs.files-json) }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Download files.json
uses: actions/download-artifact@v3
with:
name: files-json
- name: Read files.json
id: read_json
run: |
files=$(jq -r '.files[]' files.json)
echo "::set-output name=files::$files"
- name: Upload each artifact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.file }}
path: ${{ matrix.file }}