Skip to content

Commit 2c5e494

Browse files
Create action.yml
1 parent 45d6158 commit 2c5e494

1 file changed

Lines changed: 69 additions & 0 deletions

File tree

.github/workflows/action.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Extract ZIP Archives
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
paths:
7+
- '**.zip'
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: write
12+
13+
jobs:
14+
extract:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
with:
21+
token: ${{ secrets.GITHUB_TOKEN }}
22+
23+
- name: Find and extract ZIP files
24+
run: |
25+
echo "Searching for ZIP files..."
26+
find . -name "*.zip" -type f | while read -r zipfile; do
27+
# Skip files inside .git directory
28+
if echo "$zipfile" | grep -q "/.git/"; then
29+
continue
30+
fi
31+
32+
# Create extraction directory based on zip filename
33+
extract_dir="${zipfile%.zip}"
34+
35+
echo "Extracting: $zipfile -> $extract_dir"
36+
37+
# Remove existing extraction directory if present
38+
if [ -d "$extract_dir" ]; then
39+
rm -rf "$extract_dir"
40+
fi
41+
42+
# Create directory and extract
43+
mkdir -p "$extract_dir"
44+
unzip -o "$zipfile" -d "$extract_dir"
45+
46+
# Optionally remove the zip file after extraction
47+
# rm "$zipfile"
48+
# echo "Removed: $zipfile"
49+
done
50+
51+
- name: Check for changes
52+
id: git-check
53+
run: |
54+
git add -A
55+
if git diff --cached --quiet; then
56+
echo "changed=false" >> $GITHUB_OUTPUT
57+
echo "No changes to commit"
58+
else
59+
echo "changed=true" >> $GITHUB_OUTPUT
60+
echo "Changes detected"
61+
fi
62+
63+
- name: Commit and push extracted files
64+
if: steps.git-check.outputs.changed == 'true'
65+
run: |
66+
git config user.name "github-actions[bot]"
67+
git config user.email "github-actions[bot]@users.noreply.github.com"
68+
git commit -m "chore: extract zip archives [skip ci]"
69+
git push

0 commit comments

Comments
 (0)