1
- name : Gatsby Publish
1
+ # Sample workflow for building and deploying a Gatsby site to GitHub Pages
2
+ #
3
+ # To get started with Gatsby see: https://www.gatsbyjs.com/docs/quick-start/
4
+ #
5
+ name : Deploy Gatsby site to Pages
2
6
3
7
on :
8
+ # Runs on pushes targeting the default branch
4
9
push :
5
- branches :
6
- - main
10
+ branches : ["main"]
11
+
12
+ # Allows you to run this workflow manually from the Actions tab
13
+ workflow_dispatch :
14
+
15
+ # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
16
+ permissions :
17
+ contents : read
18
+ pages : write
19
+ id-token : write
20
+
21
+ # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
22
+ # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
23
+ concurrency :
24
+ group : " pages"
25
+ cancel-in-progress : false
26
+
27
+ # Default to bash
28
+ defaults :
29
+ run :
30
+ shell : bash
7
31
8
32
jobs :
33
+ # Build job
9
34
build :
10
35
runs-on : ubuntu-latest
11
36
steps :
12
- - uses : actions/checkout@v1
13
- - uses : enriikke/gatsby-gh-pages-action@v2
37
+ - name : Checkout
38
+ uses : actions/checkout@v4
39
+ - name : Detect package manager
40
+ id : detect-package-manager
41
+ run : |
42
+ if [ -f "${{ github.workspace }}/yarn.lock" ]; then
43
+ echo "manager=yarn" >> $GITHUB_OUTPUT
44
+ echo "command=install" >> $GITHUB_OUTPUT
45
+ exit 0
46
+ elif [ -f "${{ github.workspace }}/package.json" ]; then
47
+ echo "manager=npm" >> $GITHUB_OUTPUT
48
+ echo "command=ci" >> $GITHUB_OUTPUT
49
+ exit 0
50
+ else
51
+ echo "Unable to determine package manager"
52
+ exit 1
53
+ fi
54
+ - name : Setup Node
55
+ uses : actions/setup-node@v4
56
+ with :
57
+ node-version : " 20"
58
+ cache : ${{ steps.detect-package-manager.outputs.manager }}
59
+ - name : Setup Pages
60
+ id : pages
61
+ uses : actions/configure-pages@v5
14
62
with :
15
- access-token : ${{ secrets.ACCESS_TOKEN }}
16
- deploy-branch : gh-pages
63
+ # Automatically inject pathPrefix in your Gatsby configuration file.
64
+ #
65
+ # You may remove this line if you want to manage the configuration yourself.
66
+ static_site_generator : gatsby
67
+ - name : Restore cache
68
+ uses : actions/cache@v4
69
+ with :
70
+ path : |
71
+ public
72
+ .cache
73
+ key : ${{ runner.os }}-gatsby-build-${{ hashFiles('public') }}
74
+ restore-keys : |
75
+ ${{ runner.os }}-gatsby-build-
76
+ - name : Install dependencies
77
+ run : ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
78
+ - name : Build with Gatsby
79
+ env :
80
+ PREFIX_PATHS : ' true'
81
+ run : ${{ steps.detect-package-manager.outputs.manager }} run build
82
+ - name : Upload artifact
83
+ uses : actions/upload-pages-artifact@v3
84
+ with :
85
+ path : ./public
86
+
87
+ # Deployment job
88
+ deploy :
89
+ environment :
90
+ name : github-pages
91
+ url : ${{ steps.deployment.outputs.page_url }}
92
+ runs-on : ubuntu-latest
93
+ needs : build
94
+ steps :
95
+ - name : Deploy to GitHub Pages
96
+ id : deployment
97
+ uses : actions/deploy-pages@v4
0 commit comments