Last active
October 17, 2021 15:26
-
-
Save srflp/2da77871ed5e41edab913b3aaac85ba9 to your computer and use it in GitHub Desktop.
GitHub Action that checkouts the repository, gets a list of recently changed files, creates Zip archives of top-level directories and commits them back to the repo.
This file contains hidden or 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
# source: https://gist.github.com/srflp/2da77871ed5e41edab913b3aaac85ba9 | |
# put this file in <your-repo>/.github/workflows/zip-top-level-directories.yml | |
name: Zip top-level directories | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
Zip: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Get a list of recently changed files | |
id: files | |
uses: jitterbit/get-changed-files@v1 | |
- name: Zip top-level folders with their contents | |
run: echo -e ${{ steps.files.outputs.all }} | | |
tr ' ' '\n' | | |
cut -d/ -f1 | | |
sort -u | | |
egrep "^[^\.]" | | |
xargs -n1 -I % sh -c '[ -d % ] && echo "Zipping %..." && zip -r %.zip % || true' | |
- name: Commit created/updated Zip file(s) | |
run: | | |
git config user.name "ZipBot" | |
git config user.email "<>" | |
git add . | |
git commit -m "Create and/or update Zip file(s)" || echo "No changes to commit" | |
git push |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment