-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (49 loc) · 1.6 KB
/
unzip-and-deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
name: Unzip, Deploy to gh-pages, and Clean Uploads
on:
push:
branches:
- main
paths:
- 'uploads/*.zip'
jobs:
process_and_deploy:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'
- name: Extract, Deploy, and Clean
run: |
UPLOADS_DIR="uploads"
TEMP_DIR="temp_extraction"
GH_PAGES_BRANCH="gh-pages"
mkdir -p $TEMP_DIR
for zipfile in "$UPLOADS_DIR/*.zip"; do
project_name=$(basename "$zipfile" .zip)
unzip "$zipfile" -d "$TEMP_DIR"
if [ -d "$TEMP_DIR/app-files" ]; then
mv "$TEMP_DIR/app-files" "./$project_name"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git fetch origin $GH_PAGES_BRANCH
git checkout $GH_PAGES_BRANCH
git add $project_name
git commit -m "Deploy $project_name to GitHub Pages"
git push origin $GH_PAGES_BRANCH
rm "$zipfile"
else
echo "Error: 'app-files' directory not found in $zipfile"
exit 1
fi
done
git checkout main
git add -u $UPLOADS_DIR
git commit -m "Cleaned up processed ZIP files from uploads directory"
git push origin main