Extract ZIP Archives #1
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
| name: Extract ZIP Archives | |
| on: | |
| push: | |
| branches: [main, master] | |
| paths: | |
| - '**.zip' | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| extract: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Find and extract ZIP files | |
| run: | | |
| echo "Searching for ZIP files..." | |
| find . -name "*.zip" -type f | while read -r zipfile; do | |
| # Skip files inside .git directory | |
| if echo "$zipfile" | grep -q "/.git/"; then | |
| continue | |
| fi | |
| # Create extraction directory based on zip filename | |
| extract_dir="${zipfile%.zip}" | |
| echo "Extracting: $zipfile -> $extract_dir" | |
| # Remove existing extraction directory if present | |
| if [ -d "$extract_dir" ]; then | |
| rm -rf "$extract_dir" | |
| fi | |
| # Create directory and extract | |
| mkdir -p "$extract_dir" | |
| unzip -o "$zipfile" -d "$extract_dir" | |
| # Optionally remove the zip file after extraction | |
| # rm "$zipfile" | |
| # echo "Removed: $zipfile" | |
| done | |
| - name: Check for changes | |
| id: git-check | |
| run: | | |
| git add -A | |
| if git diff --cached --quiet; then | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| echo "No changes to commit" | |
| else | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| echo "Changes detected" | |
| fi | |
| - name: Commit and push extracted files | |
| if: steps.git-check.outputs.changed == 'true' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git commit -m "chore: extract zip archives [skip ci]" | |
| git push |