Build static site with Deno and deploy to GitHub Pages
To deploy your static site to GitHub Pages using the GitHub Actions CI/CD service, add the following file to your GitHub repository:
name: Deploy to GitHub Pages
on:
push:
branches: [ main ]
permissions:
contents: read
pages: write
id-token: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Deno
uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- name: Build static site
run: deno task generate
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: generated
deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
Copied!
Then configure GitHub Pages:
- On GitHub, navigate to the page of the repository:
https://github.com/your-user-name/your-repository-name/ - Click the Settings tab on the top right (possibly hiding in a
...menu). - In the Code and automation section of the left sidebar, click Pages.
- Under Source, make sure that GitHub Actions is selected.
Congratulations! Each time you push a change to your code to GitHub, it should now be auto-deployed to GitHub Pages. Point your browser to https://your-user-name.github.io/your-repository-name/ to see your live website.