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
18 changes: 0 additions & 18 deletions .github/workflows/build.yml

This file was deleted.

25 changes: 0 additions & 25 deletions .github/workflows/deploy.yml

This file was deleted.

143 changes: 143 additions & 0 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
name: Publish Docs

on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:
inputs:
pr_number:
description: 'PR number to deploy preview for'
required: true
type: number

permissions:
contents: write
pull-requests: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install dependencies
run: npm ci

- name: Determine Base URL
id: base-url
run: |
REPO_NAME="${{ github.event.repository.name }}"
OWNER="${{ github.repository_owner }}"

# Check if it's an org page (owner.github.io)
if [[ "${REPO_NAME,,}" == "${OWNER,,}.github.io" ]]; then
BASE_PATH="/"
else
BASE_PATH="/$REPO_NAME/"
fi

echo "base_path=$BASE_PATH" >> $GITHUB_OUTPUT

- name: Build
run: npm run build
env:
BASE_URL: ${{ steps.base-url.outputs.base_path }}

- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: site
path: build/

deploy-pr-preview:
if: ${{ github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: refs/pull/${{ inputs.pr_number }}/head

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install dependencies
run: npm ci

- name: Determine Base URL
id: base-url
run: |
REPO_NAME="${{ github.event.repository.name }}"
OWNER="${{ github.repository_owner }}"
PR_NUM="${{ inputs.pr_number }}"

# Check if it's an org page (owner.github.io)
if [[ "${REPO_NAME,,}" == "${OWNER,,}.github.io" ]]; then
BASE_PATH="/pr-$PR_NUM/"
FULL_URL="https://$OWNER.github.io/pr-$PR_NUM/"
else
BASE_PATH="/$REPO_NAME/pr-$PR_NUM/"
FULL_URL="https://$OWNER.github.io/$REPO_NAME/pr-$PR_NUM/"
fi

echo "base_path=$BASE_PATH" >> $GITHUB_OUTPUT
echo "full_url=$FULL_URL" >> $GITHUB_OUTPUT

- name: Build
run: npm run build
env:
BASE_URL: ${{ steps.base-url.outputs.base_path }}

- name: Deploy PR Preview
uses: JamesIves/github-pages-deploy-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages
folder: build
target-folder: pr-${{ inputs.pr_number }}
clean: true
git-config-name: github-actions[bot]
git-config-email: github-actions[bot]@users.noreply.github.com

- name: Comment Preview URL
uses: marocchino/sticky-pull-request-comment@v2
with:
recreate: true
number: ${{ inputs.pr_number }}
message: |
🚀 **Preview Ready!**
Your docs preview for this PR is available here:

**${{ steps.base-url.outputs.full_url }}**

deploy-production:
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: site
path: site

- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: site
2 changes: 1 addition & 1 deletion docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
tagline:
"Ecosystem science, policy, and management informed by the best available data and models",
url: "https://pecanproject.github.io",
baseUrl: "/",
baseUrl: process.env.BASE_URL || "/",
onBrokenLinks: "ignore",
onBrokenMarkdownLinks: "warn",
favicon: "img/favicon.ico",
Expand Down
2 changes: 1 addition & 1 deletion src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function HomepageHeader() {
className="button button--secondary button--lg"
to="/documentation/latest"
>
Get Started
Get started
</Link>
</div>
</div>
Expand Down