Skip to content

Commit 7c69095

Browse files
authored
Merge pull request #243 from sikepuri-algorithm/setup-pr-preview-action
Setup PR preview action
2 parents d53cddf + e60c7c7 commit 7c69095

File tree

7 files changed

+27
-9
lines changed

7 files changed

+27
-9
lines changed

.github/actions/build/action.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
---
2+
name: Build
3+
inputs:
4+
base-url:
5+
required: true
6+
27
runs:
3-
using: "Composite"
8+
using: Composite
49
steps:
510
- name: Install npm Modules
611
uses: ./.github/actions/install-npm-modules
712

813
- name: Build
914
run: npm run build
15+
env:
16+
BASE_URL: ${{ inputs.base-url }}
1017
shell: bash

.github/actions/execute-notebooks/action.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
2+
name: Execute Notebooks
3+
24
runs:
3-
using: "Composite"
5+
using: Composite
46
steps:
57
- name: Install Python Modules
68
uses: ./.github/actions/install-python-modules

.github/actions/install-npm-modules/action.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
2+
name: Install Node Modules
3+
24
runs:
3-
using: "Composite"
5+
using: Composite
46
steps:
57
- name: Setup Node.js
68
uses: actions/setup-node@v3

.github/actions/install-python-modules/action.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
2+
name: Install Python Modules
3+
24
runs:
3-
using: "Composite"
5+
using: Composite
46
steps:
57
- name: Setup Python
68
uses: actions/setup-python@v4

.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: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ on:
88
- reopened
99
- synchronize
1010
- closed
11-
branches-ignore:
12-
- "**"
1311

1412
concurrency: preview-${{ github.ref }}
1513

@@ -22,12 +20,17 @@ jobs:
2220
uses: actions/checkout@v3
2321

2422
- name: Execute Notebooks
25-
uses: ./.github/actions/execute_notebooks
23+
uses: ./.github/actions/execute-notebooks
24+
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
2627

2728
- name: Build
2829
uses: ./.github/actions/build
30+
with:
31+
base-url: $BASE_URL
2932

3033
- name: Deploy preview
3134
uses: rossjrw/pr-preview-action@v1
3235
with:
33-
source-dir: ./build/
36+
source-dir: build

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)