Skip to content

Commit

Permalink
ci: set up GHA
Browse files Browse the repository at this point in the history
The workflow definition is modeled after that of
loongson-community/areweloongyet.
  • Loading branch information
xen0n committed Sep 16, 2024
1 parent 57ee0d6 commit 3e047e7
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Deploy to GitHub Pages

on:
push:
branches:
- main
pull_request:

jobs:
build_and_upload:
name: Build pages and upload
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v4
- name: Set up mdBook
uses: peaceiris/actions-mdbook@v2
with:
mdbook-version: '0.4.40'
- name: Build website
run: mdbook build

- name: Upload pages artifacts (Main branch)
if: ${{ github.ref == 'refs/heads/main' }}
uses: actions/upload-pages-artifact@v3
with:
path: './book/'
name: 'gh-pages-${{github.sha}}'

- name: Upload pages artifacts (PR)
if: ${{ github.ref != 'refs/heads/main' }}
uses: actions/upload-artifact@v4
with:
path: './book/'
name: 'pages-${{github.sha}}'

deploy:
if: ${{ github.ref == 'refs/heads/main' }}
concurrency:
group: "pages"
cancel-in-progress: true
runs-on: ubuntu-latest
needs: build_and_upload
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deploy.outputs.page_url }}
steps:
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Deploy to GitHub Pages
id: deploy
uses: actions/deploy-pages@v4
with:
artifact_name: 'gh-pages-${{github.sha}}'

0 comments on commit 3e047e7

Please sign in to comment.