1
+ name : Preview Publish
2
+
3
+ on :
4
+ workflow_run :
5
+ workflows : ['Preview Build']
6
+ types :
7
+ - completed
8
+
9
+ jobs :
10
+ success :
11
+ runs-on : ubuntu-latest
12
+ if : github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
13
+ steps :
14
+ - name : download pr artifact
15
+ uses : dawidd6/action-download-artifact@v2
16
+ with :
17
+ workflow : ${{ github.event.workflow_run.workflow_id }}
18
+ name : pr
19
+ - name : save PR id
20
+ id : pr
21
+ run : echo "::set-output name=id::$(<pr-id.txt)"
22
+ - name : download _site artifact
23
+ uses : dawidd6/action-download-artifact@v2
24
+ with :
25
+ workflow : ${{ github.event.workflow_run.workflow_id }}
26
+ workflow_conclusion : success
27
+ name : _site
28
+ - run : |
29
+ unzip _site.zip
30
+
31
+ - name : Upload surge service and generate preview URL
32
+ id : deploy
33
+ run : |
34
+ export DEPLOY_DOMAIN=https://preview-pr${{ steps.pr.outputs.id }}-tdesign-vue.surge.sh
35
+ npx surge --project ./_site --domain $DEPLOY_DOMAIN --token ${{ secrets.TDESIGN_SURGE_TOKEN }}
36
+ echo the preview URL is $DEPLOY_DOMAIN
37
+
38
+ - name : update status comment
39
+ uses : actions-cool/maintain-one-comment@v1.1.0
40
+ with :
41
+ token : ${{ secrets.GITHUB_TOKEN }}
42
+ body : |
43
+ PR 预览产物在 https://preview-pr${{ steps.pr.outputs.id }}-tdesign-vue.surge.sh
44
+ number : ${{ steps.pr.outputs.id }}
45
+ - run : |
46
+ rm -rf _site/
47
+ - name : The job failed
48
+ if : ${{ failure() }}
49
+ uses : actions-cool/maintain-one-comment@v1.1.0
50
+ with :
51
+ token : ${{ secrets.GITHUB_TOKEN }}
52
+ body : |
53
+ PR 预览生成失败。
54
+ number : ${{ steps.pr.outputs.id }}
55
+
56
+ failed :
57
+ runs-on : ubuntu-latest
58
+ if : github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'failure'
59
+ steps :
60
+ - name : download pr artifact
61
+ uses : dawidd6/action-download-artifact@v2
62
+ with :
63
+ workflow : ${{ github.event.workflow_run.workflow_id }}
64
+ name : pr
65
+ - name : save PR id
66
+ id : pr
67
+ run : echo "::set-output name=id::$(<pr-id.txt)"
68
+ - name : The job failed
69
+ uses : actions-cool/maintain-one-comment@v1.1.0
70
+ with :
71
+ token : ${{ secrets.GITHUB_TOKEN }}
72
+ body : |
73
+ Deploy PR Preview failed.
74
+ number : ${{ steps.pr.outputs.id }}
0 commit comments