Skip to content
Open
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
107 changes: 107 additions & 0 deletions .github/workflows/build-and-preview-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: Build and Preview Docs

on:
pull_request_target:
branches: [master]
types: [opened, synchronize, reopened, closed]

permissions:
contents: write
pull-requests: write

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

defaults:
run:
shell: bash

jobs:
build-and-deploy-preview:
runs-on: ubuntu-24.04
env:
HUGO_VERSION: 0.157.0

steps:
- name: Checkout PR code
if: github.event.action != 'closed'
uses: actions/checkout@v6
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
persist-credentials: false
submodules: recursive
fetch-depth: 0

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

- name: Install Hugo CLI
if: github.event.action != 'closed'
run: |
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb

- name: Install Dart Sass
if: github.event.action != 'closed'
run: sudo snap install dart-sass

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

- name: Install dependencies
if: github.event.action != 'closed'
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"

- name: Build PR preview
if: github.event.action != 'closed'
env:
HUGO_ENVIRONMENT: production
HUGO_ENV: production
HUGO_PREVIEW: "true"
run: |
hugo \
--gc \
--minify \
--baseURL "/"
cat > public/robots.txt <<'EOF'
User-agent: *
Disallow: /
EOF

- name: Deploy PR preview
if: github.event.action != 'closed'
uses: rossjrw/pr-preview-action@v1.6.3
with:
source-dir: ./public
preview-branch: gh-pages
umbrella-dir: pr-preview
action: auto
comment: false

- name: Comment PR with Preview URL
if: github.event.action != 'closed'
uses: marocchino/sticky-pull-request-comment@v2
with:
header: pr-preview
message: |
🚀 **Preview deployment for PR #${{ github.event.pull_request.number }}**

🌐 **Preview URL**: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr-preview/pr-${{ github.event.pull_request.number }}/

_This preview will be updated automatically when you push new commits to this PR._
- name: Cleanup PR preview on close
if: github.event.action == 'closed'
uses: rossjrw/pr-preview-action@v1.6.3
with:
preview-branch: gh-pages
umbrella-dir: pr-preview
action: remove
45 changes: 17 additions & 28 deletions .github/workflows/hugo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,20 @@ on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
contents: write

concurrency:
group: "pages-deployment"
cancel-in-progress: true # Only latest deployment runs
group: pages-deployment
cancel-in-progress: true

# Default to bash
defaults:
run:
shell: bash

jobs:
# Build job
build:
deploy:
runs-on: ubuntu-24.04
env:
HUGO_VERSION: 0.157.0
Expand All @@ -45,34 +41,27 @@ jobs:
with:
submodules: recursive
fetch-depth: 0
- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install Node.js dependencies
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"
- name: Build with Hugo
env:
# For maximum backward compatibility with Hugo modules
HUGO_ENVIRONMENT: production
HUGO_ENV: production
run: |
hugo \
--gc \
--minify \
--baseURL "${{ steps.pages.outputs.base_url }}/"
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./public

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-24.04
needs: build
steps:
--baseURL "/"
cp CNAME public/CNAME
touch public/.nojekyll
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
publish_branch: gh-pages
keep_files: true
2 changes: 2 additions & 0 deletions hugo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
baseURL = "https://docs.layer5.io"
title = "Layer5 Documentation"
relativeURLs = true
canonifyURLs = false

# Language settings
contentDir = "content/en"
Expand Down
4 changes: 3 additions & 1 deletion layouts/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
{{ end -}}

{{ $outputFormat := partial "outputformat.html" . -}}
{{ if and hugo.IsProduction (ne $outputFormat "print") -}}
{{ if eq (getenv "HUGO_PREVIEW") "true" -}}
<meta name="robots" content="noindex, nofollow">
{{ else if and hugo.IsProduction (ne $outputFormat "print") -}}
<meta name="robots" content="index, follow">
{{ else -}}
<meta name="robots" content="noindex, nofollow">
Expand Down
3 changes: 3 additions & 0 deletions layouts/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
User-agent: *
Allow: /
Disallow: /pr-preview/
13 changes: 0 additions & 13 deletions netlify.toml

This file was deleted.

Loading