Skip to content

Commit f4fb582

Browse files
committed
fix: refactor GitHub Actions workflow for deploying static content to Pages
1 parent 2920adf commit f4fb582

File tree

1 file changed

+37
-29
lines changed

1 file changed

+37
-29
lines changed

.github/workflows/deploy-pages.yml

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,54 @@
1-
name: Deploy
1+
# Simple workflow for deploying static content to GitHub Pages
2+
name: Deploy static content to Pages
23

34
on:
5+
# Runs on pushes targeting the default branch
46
push:
5-
branches:
6-
- main
7+
branches: ['main']
78

8-
jobs:
9-
build:
10-
name: Build
11-
runs-on: ubuntu-latest
12-
13-
steps:
14-
- name: Checkout repo
15-
uses: actions/checkout@v3
9+
# Allows you to run this workflow manually from the Actions tab
10+
workflow_dispatch:
1611

17-
- name: Setup Node
18-
uses: actions/setup-node@v3
12+
# Sets the GITHUB_TOKEN permissions to allow deployment to GitHub Pages
13+
permissions:
14+
contents: read
15+
pages: write
16+
id-token: write
1917

20-
- name: Install dependencies
21-
uses: bahmutov/npm-install@v1
22-
23-
- name: Build project
24-
run: npm run build
25-
env:
26-
VITE_MAPBOX_API_KEY: ${{ secrets.VITE_MAPBOX_API_KEY }}
18+
# Allow one concurrent deployment
19+
concurrency:
20+
group: 'pages'
21+
cancel-in-progress: true
2722

28-
- name: Upload static files as artifact
29-
id: deployment
30-
uses: actions/upload-pages-artifact@v3
31-
with:
32-
path: ./dist
23+
env:
24+
VITE_MAPBOX_API_KEY: ${{ secrets.VITE_MAPBOX_API_KEY }}
3325

26+
jobs:
27+
# Single deploy job since we're just deploying
3428
deploy:
35-
permissions:
36-
pages: write
37-
id-token: write
3829
environment:
3930
name: github-pages
4031
url: ${{ steps.deployment.outputs.page_url }}
4132
runs-on: ubuntu-latest
42-
needs: build
4333
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v5
36+
- name: Set up Node
37+
uses: actions/setup-node@v5
38+
with:
39+
node-version: lts/*
40+
cache: 'npm'
41+
- name: Install dependencies
42+
run: npm ci
43+
- name: Build
44+
run: npm run build
45+
- name: Setup Pages
46+
uses: actions/configure-pages@v5
47+
- name: Upload artifact
48+
uses: actions/upload-pages-artifact@v4
49+
with:
50+
# Upload dist folder
51+
path: './dist'
4452
- name: Deploy to GitHub Pages
4553
id: deployment
4654
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)