11name : Preview_Publish
22
3+ permissions :
4+ contents : read
5+
36on :
47 workflow_run :
58 workflows :
3336
3437 - name : Set pr id
3538 id : pr
36- run : echo "id=$(cat pr-id.txt)" >> $GITHUB_OUTPUT
39+ run : |
40+ PR_ID=$(cat pr-id.txt)
41+ if [[ ! "$PR_ID" =~ ^[0-9]+$ ]]; then
42+ echo "::error::Invalid PR ID: $PR_ID"
43+ exit 1
44+ fi
45+ echo "id=$PR_ID" >> $GITHUB_OUTPUT
3746
3847 - name : site-domain
3948 id : site-domain
@@ -46,11 +55,14 @@ jobs:
4655 echo "tdesign_mobile_vue_domain=https://preview-tdesign-mobile-vue-pr-${{ steps.pr.outputs.id }}-tdesign.surge.sh" >> $GITHUB_OUTPUT
4756 echo "tdesign_mobile_react_domain=https://preview-tdesign-mobile-react-pr-${{ steps.pr.outputs.id }}-tdesign.surge.sh" >> $GITHUB_OUTPUT
4857 echo "tdesign_miniprogram_domain=https://preview-tdesign-miniprogram-pr-${{ steps.pr.outputs.id }}-tdesign.surge.sh" >> $GITHUB_OUTPUT
58+ echo "tdesign_uniapp_domain=https://preview-tdesign-uniapp-pr-${{ steps.pr.outputs.id }}-tdesign.surge.sh" >> $GITHUB_OUTPUT
4959
5060 tdesign-site :
5161 if : github.event.workflow_run.conclusion == 'success'
5262 runs-on : ubuntu-latest
5363 needs : preview-context
64+ environment :
65+ name : preview
5466 steps :
5567 - uses : dawidd6/action-download-artifact@v21
5668 with :
6577 if : github.event.workflow_run.conclusion == 'success'
6678 needs : preview-context
6779 runs-on : ubuntu-latest
80+ environment :
81+ name : preview
6882 steps :
6983 - uses : dawidd6/action-download-artifact@v21
7084 with :
8094 if : github.event.workflow_run.conclusion == 'success'
8195 needs : preview-context
8296 runs-on : ubuntu-latest
97+ environment :
98+ name : preview
8399 steps :
84100 - uses : dawidd6/action-download-artifact@v21
85101 with :
95111 if : github.event.workflow_run.conclusion == 'success'
96112 needs : preview-context
97113 runs-on : ubuntu-latest
114+ environment :
115+ name : preview
98116 steps :
99117 - uses : dawidd6/action-download-artifact@v21
100118 with :
@@ -110,6 +128,8 @@ jobs:
110128 if : github.event.workflow_run.conclusion == 'success'
111129 needs : preview-context
112130 runs-on : ubuntu-latest
131+ environment :
132+ name : preview
113133 steps :
114134 - uses : dawidd6/action-download-artifact@v21
115135 with :
@@ -125,6 +145,8 @@ jobs:
125145 if : github.event.workflow_run.conclusion == 'success'
126146 needs : preview-context
127147 runs-on : ubuntu-latest
148+ environment :
149+ name : preview
128150 steps :
129151 - uses : dawidd6/action-download-artifact@v21
130152 with :
@@ -140,6 +162,8 @@ jobs:
140162 if : github.event.workflow_run.conclusion == 'success'
141163 needs : preview-context
142164 runs-on : ubuntu-latest
165+ environment :
166+ name : preview
143167 steps :
144168 - uses : dawidd6/action-download-artifact@v21
145169 with :
@@ -155,6 +179,8 @@ jobs:
155179 if : github.event.workflow_run.conclusion == 'success'
156180 needs : preview-context
157181 runs-on : ubuntu-latest
182+ environment :
183+ name : preview
158184 steps :
159185 - uses : dawidd6/action-download-artifact@v21
160186 with :
@@ -165,11 +191,12 @@ jobs:
165191 - run : |
166192 export DEPLOY_DOMAIN=${{ needs.preview-context.outputs.tdesign_miniprogram_domain }}
167193 npx surge --project ./ --domain $DEPLOY_DOMAIN --token ${{ secrets.TDESIGN_SURGE_TOKEN }}
168-
169194 tdesign-uniapp :
170195 if : github.event.workflow_run.conclusion == 'success'
171196 needs : preview-context
172197 runs-on : ubuntu-latest
198+ environment :
199+ name : preview
173200 steps :
174201 - uses : dawidd6/action-download-artifact@v21
175202 with :
@@ -195,13 +222,15 @@ jobs:
195222 - tdesign-vue-next-chat
196223 - tdesign-uniapp
197224 runs-on : ubuntu-latest
225+ environment :
226+ name : preview
198227 steps :
199228 - name : jobs report
200229 id : report
201230 uses : actions/github-script@v9
202231 with :
203232 script : |
204- const pr_id = ${{ needs.preview-context.outputs.pr_id }};
233+ const pr_id = " ${{ needs.preview-context.outputs.pr_id }}" ;
205234
206235 const { data: { jobs } } = await github.rest.actions.listJobsForWorkflowRun({
207236 owner: context.repo.owner,
@@ -264,7 +293,7 @@ jobs:
264293 - name : comment
265294 uses : TDesignOteam/workflows/actions/maintain-one-comment@main
266295 with :
267- token : ${{ secrets.TDESIGN_BOT_TOKEN }}
296+ token : ${{ secrets.GITHUB_TOKE }}
268297 number : ${{needs.preview-context.outputs.pr_id}}
269298 body : ${{ steps.report.outputs.comment }}
270299 body-include : ' <!-- AUTO_PREVIEW_HOOK -->'
0 commit comments