Skip to content

Commit e8a01bf

Browse files
committed
Update deploy.yaml
1 parent d989774 commit e8a01bf

1 file changed

Lines changed: 70 additions & 25 deletions

File tree

.github/workflows/deploy.yaml

Lines changed: 70 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,72 @@
1-
name: Deploy React
2-
1+
name: Deploy React to github pages
32
on:
4-
push:
5-
branches: [main]
6-
7-
permissions:
8-
contents: write
9-
3+
push:
4+
branches:
5+
- main
6+
- 'feature/**'
7+
paths-ignore:
8+
- '.github/workflows/*'
9+
- README.md
10+
workflow_dispatch:
1011
jobs:
11-
deploy:
12-
runs-on: ubuntu-latest
13-
14-
steps:
15-
- uses: actions/checkout@v4
16-
17-
- uses: actions/setup-node@v4
18-
with:
19-
node-version: 20
20-
21-
- run: npm install
22-
- run: npm run build
23-
24-
- uses: peaceiris/actions-gh-pages@v4
25-
with:
26-
github_token: ${{ secrets.GITHUB_TOKEN }}
27-
publish_dir: ./dist
12+
test:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Get Code
16+
uses: actions/checkout@v4
17+
- name: Install Node 20
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: 20
21+
- name: Cache Dependencies
22+
uses: actions/cache@v4
23+
with:
24+
path: ~/.npm
25+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
26+
- name: Install Dependencies
27+
run: npm ci
28+
- name: Run Tests
29+
run: npm run test
30+
build:
31+
needs: test
32+
runs-on: ubuntu-latest
33+
steps:
34+
- name: Get Code
35+
uses: actions/checkout@v4
36+
- name: Install Node 20
37+
uses: actions/setup-node@v4
38+
with:
39+
node-version: 20
40+
- name: Cache Dependencies
41+
uses: actions/cache@v4
42+
with:
43+
path: ~/.npm
44+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
45+
- name: Install Dependencies
46+
run: npm ci
47+
- name: Build Project
48+
run: npm run build
49+
- name: Upload Dist Artifact
50+
uses: actions/upload-pages-artifact@v3
51+
with:
52+
name: github-pages
53+
path: dist
54+
deploy:
55+
needs: build
56+
runs-on: ubuntu-latest
57+
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
58+
permissions:
59+
pages: write # to deploy to Pages
60+
id-token: write # to verify the deployment originates from an appropriate source
61+
62+
# Deploy to the github-pages environment
63+
environment:
64+
name: github-pages
65+
url: ${{ steps.deployment.outputs.page_url }}
66+
67+
steps:
68+
- name: Deploy to GitHub Pages
69+
id: deployment
70+
uses: actions/deploy-pages@v4
71+
with:
72+
token: ${{secrets.GITHUB_TOKEN}}

0 commit comments

Comments
 (0)