Skip to content

Commit 0764756

Browse files
authored
Add GitHub Action to deploy to GitHub pages
1 parent c9978f3 commit 0764756

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

.github/workflows/ci-build.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Build & Deploy React App
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: Use Node.js 16.x
15+
uses: actions/setup-node@v2
16+
with:
17+
node-version: '16.x'
18+
cache: 'npm'
19+
- name: Install npm packages
20+
run: npm ci
21+
- name: Build React App
22+
run: npm run build --if-present
23+
- name: Run Tests
24+
run: npm test
25+
- name: Deploy to GitHub Pages
26+
run: |
27+
git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
28+
npm run deploy -u "github-actions-bot <[email protected]>"
29+
if: ${{ github.ref == 'refs/heads/master' }} # only deploy master
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)