add github action for deployment

This commit is contained in:
Yan Lin 2025-11-19 12:13:50 +01:00
parent 678f7576f9
commit 84f4872c4b
2 changed files with 59 additions and 0 deletions

55
.github/workflows/deploy.yml vendored Normal file
View file

@ -0,0 +1,55 @@
name: Deploy to GitHub Pages
on:
push:
branches:
- main
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
- name: Set up Python
run: uv python install
- name: Install dependencies
run: uv sync
- name: Build site
run: uv run python generate.py
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: './dist'
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

View file

@ -17,6 +17,10 @@ if __name__ == '__main__':
os.makedirs('dist/presentations', exist_ok=True)
os.makedirs('dist/teaching', exist_ok=True)
# Create .nojekyll file to prevent GitHub Pages from using Jekyll
with open('dist/.nojekyll', 'w') as f:
pass
def render_template(template_name, output_path, **kwargs):
template = env.get_template(template_name)
html = template.render(year=current_year, **kwargs)