2024-07-01 07:58:59 +00:00
|
|
|
name: Build and Deploy Static Site
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
2024-07-01 08:27:21 +00:00
|
|
|
- dev
|
2024-07-01 07:58:59 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
2024-07-01 07:59:48 +00:00
|
|
|
container: node:20-bookworm
|
2024-07-01 07:58:59 +00:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
|
|
|
|
- name: Install dependencies
|
|
|
|
run: |
|
|
|
|
apt update
|
|
|
|
apt install -y python3 python3-pip
|
2024-07-01 08:07:32 +00:00
|
|
|
python3 -m pip install -r requirements.txt --break-system-packages
|
2024-07-01 07:58:59 +00:00
|
|
|
|
|
|
|
- name: Generate static site
|
2024-07-01 08:51:01 +00:00
|
|
|
run: python3 main.py --dev
|
2024-07-01 07:58:59 +00:00
|
|
|
|
|
|
|
- name: Deploy to pages branch
|
|
|
|
run: |
|
|
|
|
# Configure Git
|
|
|
|
git config --global user.name "Forgejo"
|
|
|
|
git config --global user.email "noreply@private.coffee"
|
|
|
|
|
|
|
|
# Move generated static site files to a temporary location
|
|
|
|
mv build ../static_site_temp
|
|
|
|
|
2024-07-01 08:27:21 +00:00
|
|
|
# Create a new orphan branch named 'pages-dev'
|
|
|
|
git checkout --orphan pages-dev
|
2024-07-01 07:58:59 +00:00
|
|
|
|
|
|
|
# Remove all files from the working directory
|
|
|
|
git rm -rf .
|
|
|
|
|
|
|
|
# Move the static site files back to the working directory
|
|
|
|
mv ../static_site_temp/* ./
|
|
|
|
mv ../static_site_temp/.* ./ 2>/dev/null || true
|
|
|
|
|
|
|
|
# Add and commit the static site files
|
|
|
|
git add .
|
|
|
|
git commit -m "Deploy static site"
|
|
|
|
|
2024-07-01 08:34:16 +00:00
|
|
|
# Force push to the 'pages-dev' branch
|
|
|
|
git push origin pages-dev --force
|