Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches: [master]
workflow_dispatch:
workflow_call:

permissions:
contents: write
Expand All @@ -26,6 +25,8 @@ jobs:
run: |
make setup
make build
echo "shapes.meshery.io" > site/public/CNAME
touch site/public/.nojekyll

- name: Deploy to GitHub Pages 🚀
uses: peaceiris/actions-gh-pages@v4
Expand All @@ -34,4 +35,3 @@ jobs:
publish_dir: ./site/public
publish_branch: gh-pages
keep_files: true
cname: shapes.meshery.io
40 changes: 29 additions & 11 deletions .github/workflows/build-and-preview-site.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and Preview Site
name: PR Preview Deployment

on:
pull_request_target:
Expand All @@ -10,12 +10,13 @@ permissions:
pull-requests: write

concurrency:
group: "preview-${{ github.event.pull_request.number || github.run_id }}"
group: preview-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: true

jobs:
build-and-deploy-preview:
preview:
runs-on: ubuntu-24.04

steps:
- name: Checkout PR
if: github.event.action != 'closed'
Expand All @@ -26,23 +27,38 @@ jobs:
persist-credentials: false
fetch-depth: 0

- name: Checkout for cleanup
- name: Checkout gh-pages for cleanup
if: github.event.action == 'closed'
uses: actions/checkout@v6
with:
ref: gh-pages
fetch-depth: 0

- name: Install and Build
- name: Setup Node
if: github.event.action != 'closed'
uses: actions/setup-node@v6
with:
node-version: "20"

- name: Install dependencies
if: github.event.action != 'closed'
run: |
make setup
make build
Comment thread
saurabhraghuvanshii marked this conversation as resolved.

- name: Add robots.txt for previews
- name: Set PATH_PREFIX
if: github.event.action != 'closed'
run: |
cat > site/public/robots.txt <<'EOF'
echo "PATH_PREFIX=pr-preview/pr-${{ github.event.pull_request.number }}" >> $GITHUB_ENV

- name: Build PR preview
if: github.event.action != 'closed'
env:
GATSBY_PREVIEW: "true"
GATSBY_SITE_URL: https://${{ github.repository_owner }}.github.io
run: |
make build-preview

# Prevent indexing
cat > public/robots.txt <<'EOF'
User-agent: *
Disallow: /
EOF
Expand All @@ -63,10 +79,12 @@ jobs:
with:
header: pr-preview
message: |
🚀 Preview deployment: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr-preview/pr-${{ github.event.pull_request.number }}/
🚀 Preview deployment:
https://shapes.meshery.io/pr-preview/pr-${{ github.event.pull_request.number }}/

> *Note: Preview may take a moment (GitHub Pages deployment in progress). Please wait and refresh. Track deployment [here](https://github.com/${{ github.repository }}/actions/workflows/pages/pages-build-deployment)*

- name: Cleanup PR preview on close
- name: Cleanup PR preview
if: github.event.action == 'closed'
uses: rossjrw/pr-preview-action@v1.6.3
with:
Expand Down
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ setup:

## Build site; generate static site
build:
cd site; npm run build; cd ..
cd site; npm run build; cd ..

build-preview:
cd site; npm run build:preview; cd ..

## Build and run site
site:
Expand All @@ -46,4 +49,4 @@ lint:
docker:
docker run --name site -d --rm -p 4000:4000 -v `pwd`:"/srv/jekyll" jekyll/jekyll:4.0.0 bash -c "bundle install; jekyll serve --drafts --livereload"

.PHONY: setup-libs site-setup build docker site setup
.PHONY: setup-libs site-setup build docker site setup
7 changes: 7 additions & 0 deletions site/gatsby-config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
const rawPrefix = process.env.PATH_PREFIX;
const pathPrefix =
rawPrefix && String(rawPrefix).trim().length
? `/${String(rawPrefix).replace(/^\/+|\/+$/g, "")}`
: undefined;

/**
* @type {import('gatsby').GatsbyConfig}
*/
module.exports = {
...(pathPrefix != null ? { pathPrefix } : {}),
siteMetadata: {
title: "Meshery Shape Builder",
siteUrl: "https://shapes.meshery.io",
Expand Down
2 changes: 2 additions & 0 deletions site/package.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

{
"name": "site",
"version": "1.0.0",
Expand All @@ -11,6 +12,7 @@
"develop": "gatsby develop",
"start": "gatsby develop",
"build": "gatsby build",
"build:preview": "gatsby build --prefix-paths",
"serve": "gatsby serve",
"clean": "gatsby clean",
"lint": "eslint --fix .",
Expand Down
Loading