27
27
with :
28
28
name : site
29
29
path : " ${{ github.workspace }}/${{ env.SITE_DIR }}"
30
+
30
31
deploy_site :
31
32
runs-on : [ubuntu-latest]
32
33
needs : [build_site]
@@ -41,10 +42,60 @@ jobs:
41
42
name : site
42
43
path : " ${{ github.workspace }}/${{ env.SITE_DIR }}"
43
44
- name : Deploy to GitHub Pages
44
-
45
+ uses : JamesIves/github-pages-deploy-action@v4
46
+ with :
47
+ token : ${{ secrets.GITHUB_TOKEN }}
48
+ folder : " ${{ env.SITE_DIR }}"
49
+ commit-message : " [CI] Publish Documentation for ${{ github.sha }}"
50
+
51
+ deploy_preview :
52
+ env :
53
+ PR_PATH : pull-${{ github.event.number }}
54
+ runs-on : [ ubuntu-latest ]
55
+ needs : [ build_site ]
56
+ name : " Deploy preview for PR"
57
+ if : github.event_name == 'pull_request'
58
+ steps :
59
+ - name : Comment on PR
60
+
61
+ with :
62
+ github-token : ${{ secrets.GITHUB_TOKEN }}
63
+ repository : ${{ github.repository }}
64
+ number : ${{ github.event.number }}
65
+ id : deploy-preview
66
+ message : " Starting deployment of preview ⏳..."
67
+
68
+ - name : Set base URL for preview
69
+ run : echo "BASE_URL=https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/${{ env.PR_PATH }}/" >> $GITHUB_ENV
70
+
71
+ - name : Checkout
72
+ uses : actions/checkout@v4
73
+ - name : Download generated site
74
+ uses : actions/download-artifact@v4
75
+ with :
76
+ name : site
77
+ path : " ${{ github.workspace }}/${{ env.SITE_DIR }}"
78
+
79
+ - name : Deploy PR preview
80
+ uses : JamesIves/github-pages-deploy-action@v4
81
+ with :
82
+ token : ${{ secrets.GITHUB_TOKEN }}
83
+ folder : " ${{ env.SITE_DIR }}"
84
+ target-folder : " ${{ env.PR_PATH }}"
85
+ commit-message : " [CI] Publish Preview for PR #${{ github.event.number }}"
86
+
87
+ - name : Update comment
88
+
45
89
with :
46
- # ACCESS_TOKEN: # optional
47
- GITHUB_TOKEN : " ${{ github.token}}"
48
- FOLDER : " ${{ env.SITE_DIR }}"
49
- BRANCH : " gh-pages"
50
- COMMIT_MESSAGE : " [CI] Publish Documentation for ${{ github.sha }}"
90
+ github-token : ${{ secrets.GITHUB_TOKEN }}
91
+ repository : ${{ github.repository }}
92
+ number : ${{ github.event.number }}
93
+ id : deploy-preview
94
+ message : |
95
+ A preview of ${{ github.event.after }} is uploaded and can be seen here:
96
+
97
+ ✨ ${{ env.BASE_URL }} ✨
98
+
99
+ Changes may take a few minutes to propagate.
100
+
101
+ The source is here: https://github.com/${{ github.repository }}/tree/gh-pages/${{ env.PR_PATH }}/
0 commit comments