1- name : Deploy React to github pages
1+ name : Deploy React to GitHub Pages
2+
23on :
3- push :
4- branches :
5- - main
6- - ' feature/**'
7- paths-ignore :
8-
9- - README.md
10- workflow_dispatch :
4+ push :
5+ branches :
6+ - main
7+ paths-ignore :
8+ - README.md
9+ workflow_dispatch :
10+
1111jobs :
12-
13- build :
14- runs-on : ubuntu-latest
15- steps :
16- - name : Get Code
17- uses : actions/checkout@v4
18- - name : Install Node 20
19- uses : actions/setup-node@v4
20- with :
21- node-version : 20
22- - name : Cache Dependencies
23- uses : actions/cache@v4
24- with :
25- path : ~/.npm
26- key : ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
27- - name : Install Dependencies
28- run : npm install
29- - name : Build Project
30- run : npm run build
31- - name : Upload Dist Artifact
32- uses : actions/upload-pages-artifact@v3
33- with :
34- name : github-pages
35- path : dist
36- deploy :
37- needs : build
38- runs-on : ubuntu-latest
39- # Grant GITHUB_TOKEN the permissions required to make a Pages deployment
40- permissions :
41- pages : write # to deploy to Pages
42- id-token : write # to verify the deployment originates from an appropriate source
43-
44- # Deploy to the github-pages environment
45- environment :
12+ build :
13+ runs-on : ubuntu-latest
14+ steps :
15+ - name : Get Code
16+ uses : actions/checkout@v4
17+
18+ - name : Install Node 20
19+ uses : actions/setup-node@v4
20+ with :
21+ node-version : 20
22+
23+ - name : Cache Dependencies
24+ uses : actions/cache@v4
25+ with :
26+ path : ~/.npm
27+ key : ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
28+
29+ - name : Install Dependencies
30+ run : npm install
31+
32+ - name : Build Project
33+ run : npm run build
34+
35+ - name : Upload Dist Artifact
36+ uses : actions/upload-pages-artifact@v3
37+ with :
4638 name : github-pages
47- url : ${{ steps.deployment.outputs.page_url }}
48-
49- steps :
50- - name : Deploy to GitHub Pages
51- id : deployment
52- uses : actions/deploy-pages@v4
53- with :
54- token : ${{secrets.GITHUB_TOKEN}}
39+ path : dist
40+
41+ deploy :
42+ needs : build
43+ runs-on : ubuntu-latest
44+ permissions :
45+ pages : write
46+ id-token : write
47+
48+ environment :
49+ name : github-pages
50+
51+ steps :
52+ - name : Deploy to GitHub Pages
53+ id : deployment
54+ uses : actions/deploy-pages@v4
55+ with :
56+ token : ${{ secrets.GITHUB_TOKEN }}
57+
58+ - name : Show Deployed URL
59+ run : echo "Deployed at ${{ steps.deployment.outputs.page_url }}"
0 commit comments