Skip to content

Commit 327ca9d

Browse files
authored
Merge pull request #245 from sikepuri-algorithm/update-actions
Update preview action
2 parents 70675b1 + 0a01f03 commit 327ca9d

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

.github/workflows/preview.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,20 @@ jobs:
2323
uses: ./.github/actions/execute-notebooks
2424

2525
- name: Make BASE_URL
26-
run: echo ${{ github.ref }} | sed "s/[^0-9]//g" | (v=$(cat); echo -e "BASE_URL=/pr-preview/pr-$v/" ) >> $GITHUB_ENV
26+
uses: actions/github-script@v6
27+
id: base-url
28+
with:
29+
script: |
30+
const refName = "${{ github.ref_name }}"; // PR_NUMBER/merge
31+
const prNumber = refName.slice(0, refName.length - 6);
32+
const baseUrl = `/pr-preview/pr-${prNumber}/`;
33+
return baseUrl;
34+
result-encoding: string
2735

2836
- name: Build
2937
uses: ./.github/actions/build
3038
with:
31-
base-url: $BASE_URL
39+
base-url: ${{ steps.base-url.outputs.result }}
3240

3341
- name: Deploy preview
3442
uses: rossjrw/pr-preview-action@v1

docusaurus.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const config = {
1313
title: "Introduction to Algorithms",
1414
// tagline: '',
1515
url: "https://sikepuri-algorithm.github.io",
16-
baseUrl: process.env.NODE_ENV ? "/" : process.env.BASE_URL,
16+
baseUrl: process.env.NODE_ENV === "development" ? "/" : process.env.BASE_URL,
1717
onBrokenLinks: "throw",
1818
onBrokenMarkdownLinks: "warn",
1919
favicon: "img/favicon.ico",

0 commit comments

Comments
 (0)