Skip to content

Commit a610812

Browse files
committed
Create github workflow file
1 parent 680f8b5 commit a610812

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

.github/workflows/deploy-react-app

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: React App Deployment # name of the workflo
2+
3+
on:
4+
push:
5+
branches:
6+
- deploy-react-app # branch name
7+
8+
jobs:
9+
deploy-react-to-gh-pages:
10+
runs-on: ubuntu-latest
11+
env:
12+
EXAMPLE: example # environment variable
13+
defaults:
14+
run:
15+
working-directory: ./react-deployment-example
16+
steps:
17+
# checkout the repository content to github runner
18+
- name: Checkout
19+
uses: actions/checkout@v2
20+
21+
# setup nodejs environment
22+
- name: Setup Node.js environment
23+
uses: actions/[email protected]
24+
with:
25+
node-version: "18.16.1"
26+
27+
# cache the dependencies to speed up the build
28+
- name: Cache dependencies
29+
uses: actions/cache@v2
30+
with:
31+
path: ~/.npm
32+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
33+
restore-keys: |
34+
${{ runner.os }}-node-
35+
36+
# install dependencies
37+
- name: Install dependencies
38+
run: npm i
39+
40+
# build the react app
41+
- name: Build
42+
run: npm run build
43+
44+
# deploy the react app to github pages
45+
- name: Deploy
46+
uses: peaceiris/actions-gh-pages@v3
47+
with:
48+
# NOTE: GITHUB_TOKEN is a secret token that is automatically generated by GitHub
49+
github_token: ${{ secrets.GITHUB_TOKEN }}
50+
publish_dir: ./build # directory to deploy

0 commit comments

Comments
 (0)