From 84f4872c4bf483be0561846c34cdf0abe8908f85 Mon Sep 17 00:00:00 2001 From: Yan Lin Date: Wed, 19 Nov 2025 12:13:50 +0100 Subject: [PATCH] add github action for deployment --- .github/workflows/deploy.yml | 55 ++++++++++++++++++++++++++++++++++++ generate.py | 4 +++ 2 files changed, 59 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..9415d7f --- /dev/null +++ b/.github/workflows/deploy.yml @@ -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 diff --git a/generate.py b/generate.py index 8dbc8c9..1497a6d 100644 --- a/generate.py +++ b/generate.py @@ -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)