Skip to content

Commit 97b40e5

Browse files
committed
GitHub Action to deploy to GitHub Pages
1 parent bad18ba commit 97b40e5

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
# Runs on pushes targeting the default branch
5+
push:
6+
branches: [$default-branch]
7+
8+
# Allows you to run this workflow manually from the Actions tab
9+
workflow_dispatch:
10+
11+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
12+
permissions:
13+
contents: read
14+
pages: write
15+
id-token: write
16+
17+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
18+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
19+
concurrency:
20+
group: "pages"
21+
cancel-in-progress: false
22+
23+
24+
jobs:
25+
build:
26+
name: Deploy to GitHub Pages
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v4
30+
- uses: actions/setup-node@v4
31+
with:
32+
node-version: 22
33+
cache: npm
34+
- name: Setup Pages
35+
id: pages
36+
uses: actions/configure-pages@v5
37+
# with:
38+
# Automatically inject pathPrefix in your Gatsby configuration file.
39+
#
40+
# You may remove this line if you want to manage the configuration yourself.
41+
# static_site_generator: gatsby
42+
# - name: Restore cache
43+
# uses: actions/cache@v4
44+
# with:
45+
# path: |
46+
# static
47+
# .cache
48+
# key: ${{ runner.os }}-docusaurus-build-${{ hashFiles('static') }}
49+
# restore-keys: |
50+
# ${{ runner.os }}-docusaurus-build-
51+
- name: Install dependencies
52+
run: npm ci
53+
- name: Build with Docusaurus
54+
run: npm run build
55+
- name: Upload artifact
56+
uses: actions/upload-pages-artifact@v3
57+
with:
58+
path: ./build
59+
60+
# Deployment job
61+
deploy:
62+
environment:
63+
name: github-pages
64+
url: ${{ steps.deployment.outputs.page_url }}
65+
runs-on: ubuntu-latest
66+
needs: build
67+
steps:
68+
- name: Deploy to GitHub Pages
69+
id: deployment
70+
uses: actions/deploy-pages@v4
71+

.github/workflows/test-build.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Test deployment
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
# Review gh actions docs if you want to further define triggers, paths, etc
8+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on
9+
10+
jobs:
11+
test-deploy:
12+
name: Test deployment
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: actions/setup-node@v4
17+
with:
18+
node-version: 22
19+
cache: npm
20+
21+
- name: Install dependencies
22+
run: npm install
23+
- name: Test build website
24+
run: npm run build

docusaurus.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const config = {
2222
// If you aren't using GitHub pages, you don't need these.
2323
organizationName: 'LBHackney-IT', // Usually your GitHub org/user name.
2424
projectName: 'lbhackney-it.github.io', // Usually your repo name.
25+
trailingSlash: true,
2526

2627
onBrokenLinks: 'throw',
2728
onBrokenMarkdownLinks: 'warn',

0 commit comments

Comments
 (0)