Build GitHub Pages #2070
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: Build GitHub Pages | |
on: | |
push: | |
branches: main | |
schedule: | |
- cron: '0 5 * * *' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout main repository | |
uses: actions/checkout@v4 | |
- name: Checkout gh-pages branch | |
uses: actions/checkout@v4 | |
with: | |
path: gh_pages | |
ref: gh-pages | |
- name: Set up Python 3.x | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Install required Python libraries | |
run: pip install lxml | |
- name: Install Docker Compose | |
run: | | |
sudo curl -L "https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | |
sudo chmod +x /usr/local/bin/docker-compose | |
docker-compose --version | |
- name: Build website and documentation | |
env: | |
GITHUB_TOKEN: ${{ secrets.PERSONAL_TOKEN }} | |
GOOGLE_ANALYTICS_ID: ${{ secrets.GOOGLE_ANALYTICS_ID }} | |
NODE_ENV: production | |
BUILD_DIR: ${{ github.workspace }}/gh_pages | |
run: | | |
make prod | |
# Create .nojekyll file to disable Jekyll processing | |
touch "${BUILD_DIR}/.nojekyll" | |
# Set permissions for _next and assets directories | |
if [ -d "${BUILD_DIR}/_next" ]; then | |
chmod -R 755 "${BUILD_DIR}/_next" | |
fi | |
if [ -d "${BUILD_DIR}/assets" ]; then | |
chmod -R 755 "${BUILD_DIR}/assets" | |
fi | |
# Verify the structure | |
echo "Main build directory contents:" | |
ls -la "${BUILD_DIR}" | |
echo "_next directory contents:" | |
ls -la "${BUILD_DIR}/_next" || true | |
echo "Assets directory contents:" | |
ls -la "${BUILD_DIR}/assets" || true | |
- name: Generate sitemap | |
run: | | |
pip install lxml | |
python tools/generate_sitemap.py "${{ github.workspace }}/gh_pages" | |
- name: Commit and push changes | |
run: | | |
cd "${{ github.workspace }}/gh_pages" | |
git config --global user.name "GitHub Action" | |
git config --global user.email "[email protected]" | |
git add . | |
git diff-index --quiet HEAD || git commit -m "Build $(date +"%Y-%m-%d %H:%M:%S"). ${GITHUB_SHA::8}. Event: ${GITHUB_EVENT_NAME}." | |
git push origin gh-pages |