Skip to content

Commit d772eb6

Browse files
committed
Refactor GitHub Actions workflow for deploying to GitHub Pages; streamline Node.js setup and build steps
1 parent 7f7f24c commit d772eb6

File tree

1 file changed

+35
-28
lines changed

1 file changed

+35
-28
lines changed

.github/workflows/actions.yaml

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,48 @@
1-
name: GitHub Actions
1+
name: Deploy to GitHub Pages
22

33
on:
4-
pull_request:
5-
branches:
6-
- main
74
push:
85
branches:
9-
- main
6+
- main # Set this to your default branch
7+
permissions:
8+
id-token: write
9+
contents: read
10+
pages: write
1011

1112
jobs:
1213
build:
1314
runs-on: ubuntu-latest
14-
strategy:
15-
matrix:
16-
node-version:
17-
- 18
18-
- 20
19-
- 22
15+
2016
steps:
21-
- uses: actions/checkout@v4
22-
- name: Use Node.js v${{ matrix.node-version }}
23-
uses: actions/setup-node@v4
17+
- name: Checkout code
18+
uses: actions/checkout@v3
19+
20+
- name: Set up Node.js
21+
uses: actions/setup-node@v3
2422
with:
25-
node-version: ${{ matrix.node-version }}
26-
cache: npm
27-
- run: npm ci
28-
- run: npm run build
29-
# - run: npm test
23+
node-version: '20.18.1' # Use the version of Node.js your project requires
24+
25+
- name: Install dependencies
26+
run: npm install
27+
28+
- name: Build Astro Starlight project
29+
run: npm run build
3030

31-
check:
31+
- name: Verify build contents
32+
run: ls -R ./dist
33+
34+
- name: Upload build artifacts
35+
uses: actions/upload-pages-artifact@v3
36+
with:
37+
path: ./dist
38+
39+
deploy:
40+
needs: build
3241
runs-on: ubuntu-latest
42+
environment:
43+
name: github-pages
44+
url: ${{ steps.deploy.outputs.page_url }}
3345
steps:
34-
- uses: actions/checkout@v4
35-
- name: Use Node.js 22
36-
uses: actions/setup-node@v4
37-
with:
38-
node-version: 22
39-
cache: npm
40-
- run: npm ci
41-
- run: npm run check
46+
- name: Deploy to GitHub Pages
47+
id: deploy
48+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)