Skip to content

Commit a77349b

Browse files
committed
trying another action
Signed-off-by: Aritra Dey <[email protected]>
1 parent 34b8156 commit a77349b

File tree

2 files changed

+8
-103
lines changed

2 files changed

+8
-103
lines changed

.github/workflows/publish-docs.yml

Lines changed: 7 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish Docs
1+
name: Build, Deploy to GitHub Pages and Deploy PR Preview
22

33
on:
44
push:
@@ -14,109 +14,14 @@ permissions:
1414
contents: write
1515
pull-requests: write
1616

17-
concurrency: preview-${{ github.ref }}
18-
19-
env:
20-
PREVIEW_BRANCH: gh-pages
17+
concurrency: ci-${{ github.ref }}
2118

2219
jobs:
23-
deploy-preview:
24-
runs-on: ubuntu-latest
25-
if: ${{ github.event_name == 'pull_request' }}
26-
steps:
27-
- name: Checkout
28-
uses: actions/checkout@v4
29-
30-
- name: Setup Node.js
31-
uses: actions/setup-node@v4
32-
with:
33-
node-version: 20
34-
35-
- name: Calculate BASE_URL
36-
run: |
37-
REPO="${{ github.event.repository.name }}"
38-
OWNER="${{ github.repository_owner }}"
39-
40-
if [[ "$REPO" == "$OWNER.github.io" ]]; then
41-
echo "BASE_URL=/pr-preview/pr-${{ github.event.pull_request.number }}/" >> $GITHUB_ENV
42-
else
43-
echo "BASE_URL=/$REPO/pr-preview/pr-${{ github.event.pull_request.number }}/" >> $GITHUB_ENV
44-
fi
45-
46-
- name: Install and Build
47-
run: npm ci && npm run build
48-
env:
49-
BASE_URL: ${{ env.BASE_URL }}
50-
51-
52-
- name: Deploy Preview
53-
uses: rossjrw/pr-preview-action@v1
54-
id: preview-step
55-
with:
56-
source-dir: build/
57-
preview-branch: ${{ env.PREVIEW_BRANCH }}
58-
comment: false
59-
60-
- name: Comment Preview URL (Success)
61-
uses: marocchino/sticky-pull-request-comment@v2
62-
if: steps.preview-step.outputs.deployment-action == 'deploy' && env.deployment_status == 'success'
63-
with:
64-
header: pr-preview
65-
message: |
66-
[PR Preview Action](https://github.com/rossjrw/pr-preview-action) ${{ steps.preview-step.outputs.action-version }}
67-
:---:
68-
| <p></p> :rocket: View preview at <br> ${{ steps.preview-step.outputs.preview-url }} <br><br>
69-
| <h6>Built to branch [`${{ env.PREVIEW_BRANCH }}`](${{ github.server_url }}/${{ github.repository }}/tree/${{ env.PREVIEW_BRANCH }}) at ${{ steps.preview-step.outputs.action-start-time }}. <br> Preview will be ready when the [GitHub Pages deployment](${{ github.server_url }}/${{ github.repository }}/deployments) is complete. <br><br> </h6>
70-
71-
- name: Comment Preview Removed
72-
uses: marocchino/sticky-pull-request-comment@v2
73-
if: steps.preview-step.outputs.deployment-action == 'remove' && env.deployment_status == 'success'
74-
with:
75-
header: pr-preview
76-
message: |
77-
[PR Preview Action](https://github.com/rossjrw/pr-preview-action) ${{ steps.preview-step.outputs.action-version }}
78-
:---:
79-
Preview removed because the pull request was closed.
80-
${{ steps.preview-step.outputs.action-start-time }}
81-
82-
build-production:
20+
build-deploy-and-preview:
21+
name: Build, Deploy to GitHub Pages and Deploy PR Preview
8322
runs-on: ubuntu-latest
84-
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
8523
steps:
86-
- name: Checkout
87-
uses: actions/checkout@v4
88-
89-
- name: Setup Node.js
90-
uses: actions/setup-node@v4
91-
with:
92-
node-version: 20
93-
94-
- name: Install dependencies
95-
run: npm ci
96-
97-
- name: Build
98-
run: npm run build
99-
100-
- name: Upload build artifact
101-
uses: actions/upload-artifact@v4
102-
with:
103-
name: site
104-
path: build/
105-
106-
deploy-production:
107-
runs-on: ubuntu-latest
108-
needs: build-production
109-
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
110-
steps:
111-
- name: Download build artifact
112-
uses: actions/download-artifact@v4
113-
with:
114-
name: site
115-
path: site
116-
117-
- name: Deploy to GitHub Pages
118-
uses: JamesIves/github-pages-deploy-action@v4
24+
- name: Build, Deploy to GitHub Pages and Deploy PR Preview
25+
uses: chvmvd/[email protected]
11926
with:
120-
branch: gh-pages
121-
folder: site
122-
clean-exclude: pr-preview
27+
type: docusaurus

docusaurus.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module.exports = {
44
tagline:
55
"Ecosystem science, policy, and management informed by the best available data and models",
66
url: "https://pecanproject.github.io",
7-
baseUrl: process.env.BASE_URL || "/",
7+
baseUrl: process.env.GITHUB_ACTIONS ? `${process.env.BASE_URL}/` : "/",
88
onBrokenLinks: "ignore",
99
onBrokenMarkdownLinks: "warn",
1010
favicon: "img/favicon.ico",

0 commit comments

Comments
 (0)