Concludes local merge. #5
This file contains 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: 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 |