Skip to content

Commit d7d05a1

Browse files
committed
Update GitHub Actions: Set PUBLIC_URL dynamically for branch-based deployment
1 parent 29ff1f9 commit d7d05a1

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

.github/workflows/build-deploy-zodiac.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ jobs:
1919
- name: Install dependencies
2020
run: yarn install --frozen-lockfile
2121

22-
- name: Build React App
23-
run: yarn build
22+
- name: Build React App with Dynamic PUBLIC_URL
23+
run: |
24+
echo "Building for /dev/${{ env.BRANCH_NAME}}/"
25+
PUBLIC_URL="/dev/${{ env.BRANCH_NAME}}/" yarn build
2426
2527
- name: Determine Branch Name
2628
id: get_branch

src/App.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import theme from "design/theme";
44
import { BrowserRouter } from "react-router-dom";
55

66
const App = () => {
7-
return (
8-
<ThemeProvider theme={theme}>
9-
<BrowserRouter>
10-
<Routes />
11-
</BrowserRouter>
12-
</ThemeProvider>
13-
);
7+
return (
8+
<ThemeProvider theme={theme}>
9+
<BrowserRouter basename={process.env.PUBLIC_URL}>
10+
<Routes />
11+
</BrowserRouter>
12+
</ThemeProvider>
13+
);
1414
};
1515

1616
export default App;

0 commit comments

Comments
 (0)