Skip to content

Commit 8a96be8

Browse files
committed
Create gatsby.yml
1 parent c5e9b3f commit 8a96be8

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed

.github/workflows/gatsby.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
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
6+
7+
on:
8+
# Runs on pushes targeting the default branch
9+
push:
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
31+
32+
jobs:
33+
# Build job
34+
build:
35+
runs-on: ubuntu-latest
36+
steps:
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
62+
with:
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: **=
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

Comments
 (0)