Skip to content

Commit ad58868

Browse files
authored
Merge branch 'master' into add-card-component-docs
2 parents 229d91b + 916f75e commit ad58868

File tree

37 files changed

+1219
-332
lines changed

37 files changed

+1219
-332
lines changed
Lines changed: 35 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,43 @@
1-
name: Build and Deploy Site
1+
name: Deploy Gatsby site to Pages
2+
23
on:
34
push:
45
branches: [master]
5-
paths-ignore:
6-
- .github/*
7-
86
workflow_dispatch:
9-
workflow_call:
10-
7+
8+
permissions:
9+
contents: write
10+
11+
concurrency:
12+
group: "pages-deployment"
13+
cancel-in-progress: true
14+
1115
jobs:
12-
build-and-deploy:
13-
runs-on: ubuntu-latest
16+
deploy:
17+
runs-on: ubuntu-24.04
18+
1419
steps:
15-
- name: Checkout 🛎️
16-
uses: actions/checkout@master
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Setup Node
24+
uses: actions/setup-node@v4
1725
with:
18-
fetch-depth: 1
19-
20-
# - name: Cache Gatsby .cache and public folders
21-
# uses: actions/cache@v5
22-
# id: gatsby-cache
23-
# with:
24-
# path: |
25-
# public
26-
# .cache
27-
# key: ${{ runner.os }}-gatsby-${{ hashFiles('**/package-lock.json') }}
28-
# restore-keys: |
29-
# ${{ runner.os }}-gatsby-
30-
31-
- name: Install 🔧
32-
run: make setup
33-
34-
- name: Build 🏗️
35-
# Always run the full production build explicitly.
36-
# Do NOT use `make clean` here — that target is a developer convenience
37-
# command whose recipe has changed multiple times, causing blog posts and
38-
# other collections to be silently excluded from the deployed site when
39-
# it ran a lite/dev build instead of the full production build.
40-
# `npm run build` is the canonical, stable production build command:
41-
# cross-env BUILD_FULL_SITE=true gatsby build
42-
run: npm run build
43-
44-
- name: Deploy 🚀
45-
uses: JamesIves/github-pages-deploy-action@v4
26+
node-version: "20"
27+
28+
- name: Install dependencies
29+
run: npm ci
30+
31+
- name: Build Gatsby site
32+
run: |
33+
npm run build
34+
echo "layer5.io" > public/CNAME
35+
touch public/.nojekyll
36+
37+
- name: Deploy to GitHub Pages
38+
uses: peaceiris/actions-gh-pages@v4
4639
with:
47-
branch: site # The branch the action should deploy to.
48-
folder: public # The folder the action should deploy.
49-
clean: true
40+
github_token: ${{ secrets.GITHUB_TOKEN }}
41+
publish_dir: ./public
42+
publish_branch: gh-pages
43+
keep_files: true
Lines changed: 73 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,84 @@
1-
name: Build and Preview Site
1+
name: PR Preview Deployment (Gatsby + GitHub Pages)
2+
23
on:
3-
pull_request:
4+
pull_request_target:
45
branches: [master]
5-
types: [opened, synchronize, reopened]
6+
types: [opened, synchronize, reopened, closed]
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
concurrency:
13+
group: preview-${{ github.event.pull_request.number || github.run_id }}
14+
cancel-in-progress: true
615

716
jobs:
8-
site-preview:
17+
preview:
918
runs-on: ubuntu-latest
19+
1020
steps:
11-
- name: Checkout 🛎️
12-
uses: actions/checkout@master
21+
22+
- name: Checkout PR
23+
if: github.event.action != 'closed'
24+
uses: actions/checkout@v4
25+
with:
26+
ref: ${{ github.event.pull_request.head.sha }}
27+
28+
- name: Checkout gh-pages for cleanup
29+
if: github.event.action == 'closed'
30+
uses: actions/checkout@v4
1331
with:
14-
persist-credentials: false
15-
fetch-depth: 1
16-
17-
- name: Install 🔧
18-
run: make setup
19-
20-
- name: Build 🏗️
21-
# Always run the full production build explicitly.
22-
# Do NOT use `make clean` here — that target is a developer convenience
23-
# command whose recipe has changed multiple times, causing blog posts and
24-
# other collections to be silently excluded from the deployed site when
25-
# it ran a lite/dev build instead of the full production build.
26-
# `npm run build` is the canonical, stable production build command:
27-
# cross-env BUILD_FULL_SITE=true gatsby build
28-
run: npm run build
29-
30-
- name: Broken Link Check 🔗
31-
uses: technote-space/broken-link-checker-action@v2
32+
ref: gh-pages
33+
34+
- name: Setup Node
35+
if: github.event.action != 'closed'
36+
uses: actions/setup-node@v4
3237
with:
33-
target: ./public/**/*.html
38+
node-version: "20"
3439

35-
- name: Zip Site
36-
run: bash ./script.sh
40+
- name: Install dependencies
41+
if: github.event.action != 'closed'
42+
run: npm ci
43+
44+
- name: Set PATH_PREFIX for preview
45+
if: github.event.action != 'closed'
46+
run: |
47+
echo "PATH_PREFIX=pr-preview/pr-${{ github.event.pull_request.number }}" >> $GITHUB_ENV
48+
49+
- name: Build PR preview
50+
if: github.event.action != 'closed'
51+
env:
52+
GATSBY_PREVIEW: "true"
53+
GATSBY_SITE_URL: https://${{ github.repository_owner }}.github.io
54+
run: |
55+
PATH_PREFIX=$PATH_PREFIX npm run build:preview
56+
57+
# Prevent indexing
58+
echo -e "User-agent: *\nDisallow: /" > public/robots.txt
59+
60+
- name: Deploy PR preview
61+
if: github.event.action != 'closed'
62+
uses: rossjrw/pr-preview-action@v1.6.3
63+
with:
64+
source-dir: ./public
65+
preview-branch: gh-pages
66+
umbrella-dir: pr-preview
67+
action: auto
68+
comment: false
69+
70+
- name: Comment PR with Preview URL
71+
if: github.event.action != 'closed'
72+
uses: marocchino/sticky-pull-request-comment@v2
73+
with:
74+
header: pr-preview
75+
message: |
76+
🚀 Preview deployment: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr-preview/pr-${{ github.event.pull_request.number }}/
3777
38-
- name: Upload files
39-
uses: actions/upload-artifact@v6
78+
- name: Cleanup PR preview
79+
if: github.event.action == 'closed'
80+
uses: rossjrw/pr-preview-action@v1.6.3
4081
with:
41-
name: public-dir
42-
path: ./public-dir.zip
43-
retention-days: 1
44-
- name: Trigger Inner workflow
45-
run: echo "triggering inner workflow"
82+
preview-branch: gh-pages
83+
umbrella-dir: pr-preview
84+
action: remove

.github/workflows/preview-site.yml

Lines changed: 0 additions & 48 deletions
This file was deleted.

gatsby-config.js

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ const {
88

99
const isDevelopment = process.env.NODE_ENV === "development";
1010
const isProduction = process.env.NODE_ENV === "production";
11+
const isPreviewBuild = process.env.GATSBY_PREVIEW === "true";
12+
const siteOrigin = (process.env.GATSBY_SITE_URL || "https://layer5.io").replace(
13+
/\/$/,
14+
"",
15+
);
16+
const rawPathPrefix = process.env.PATH_PREFIX || "";
17+
const pathPrefix = rawPathPrefix
18+
? `/${rawPathPrefix.replace(/^\/+|\/+$/g, "")}`
19+
: "";
20+
const siteRootUrl = `${siteOrigin}${pathPrefix}`.replace(/\/$/, "");
1121
const shouldBuildFullSite = isFullSiteBuild();
1222
const isLiteDevBuild = isDevelopment && !shouldBuildFullSite;
1323
const excludedCollections = getExcludedCollections({
@@ -34,11 +44,12 @@ module.exports = {
3444
description:
3545
"Expect more from your infrastructure. Cloud native, open source software for your internal development platforms, your DevOps, platform engineering and site reliability engineering teams. Less finger-pointing and more collaborating. Allowing developers to focus on business logic, not infrastructure concerns. Empowering operators to confidently run modern infrastructure.",
3646
author: "Layer5 Authors",
37-
permalink: "https://layer5.io",
38-
siteUrl: "https://layer5.io",
47+
permalink: siteRootUrl,
48+
siteUrl: siteRootUrl,
3949
image: "/images/layer5-gradient.webp",
4050
twitterUsername: "@layer5",
4151
},
52+
...(pathPrefix ? { pathPrefix } : {}),
4253
flags: {
4354
FAST_DEV: false,
4455
DEV_SSR: false,
@@ -560,14 +571,18 @@ module.exports = {
560571
query: "allMdx",
561572
},
562573
},
563-
{
564-
resolve: "gatsby-plugin-robots-txt",
565-
options: {
566-
host: "https://layer5.io",
567-
sitemap: "https://layer5.io/sitemap-index.xml",
568-
policy: [{ userAgent: "*", allow: "/" }],
569-
},
570-
},
574+
...(!isPreviewBuild
575+
? [
576+
{
577+
resolve: "gatsby-plugin-robots-txt",
578+
options: {
579+
host: siteRootUrl,
580+
sitemap: `${siteRootUrl}/sitemap-index.xml`,
581+
policy: [{ userAgent: "*", allow: "/" }],
582+
},
583+
},
584+
]
585+
: []),
571586
"gatsby-plugin-meta-redirect",
572587
// make sure this is always the last one
573588
],

0 commit comments

Comments
 (0)