Skip to content

Commit e60c7c7

Browse files
committed
Fix preview action to be able to make PR preview
1 parent ff3be18 commit e60c7c7

4 files changed

Lines changed: 13 additions & 1 deletion

File tree

.github/actions/build/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
---
22
name: Build
3+
inputs:
4+
base-url:
5+
required: true
36

47
runs:
58
using: Composite
@@ -9,4 +12,6 @@ runs:
912

1013
- name: Build
1114
run: npm run build
15+
env:
16+
BASE_URL: ${{ inputs.base-url }}
1217
shell: bash

.github/workflows/build-test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ jobs:
1515

1616
- name: Build
1717
uses: ./.github/actions/build
18+
with:
19+
base-url: /

.github/workflows/preview.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,13 @@ jobs:
2222
- name: Execute Notebooks
2323
uses: ./.github/actions/execute-notebooks
2424

25+
- name: Calculate BASE_URL
26+
run: echo ${{ github.ref }} | sed "s/[^0-9]//g" | (v=$(cat); echo -e "BASE_URL=/pr-preview/pr-$v/" ) >> $GITHUB_ENV
27+
2528
- name: Build
2629
uses: ./.github/actions/build
30+
with:
31+
base-url: $BASE_URL
2732

2833
- name: Deploy preview
2934
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: "/",
16+
baseUrl: process.env.BASE_URL,
1717
onBrokenLinks: "throw",
1818
onBrokenMarkdownLinks: "warn",
1919
favicon: "img/favicon.ico",

0 commit comments

Comments
 (0)