1
+ name : Preview Deploy
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
+
20
+ - name : save PR id
21
+ id : pr
22
+ run : echo "::set-output name=id::$(<pr.txt)"
23
+
24
+ - name : download docs artifact
25
+ uses : dawidd6/action-download-artifact@v2
26
+ with :
27
+ workflow : ${{ github.event.workflow_run.workflow_id }}
28
+ workflow_conclusion : success
29
+ name : docs
30
+
31
+ - name : upload surge service
32
+ id : deploy
33
+ run : |
34
+ export DEPLOY_DOMAIN=https://preview-pr-${{ steps.pr.outputs.id }}-element-ui.surge.sh
35
+ npx surge --project ./ --domain $DEPLOY_DOMAIN --token ${{ secrets.SURGE_TOKEN }}
36
+
37
+ - name : update status comment
38
+ uses :
actions-cool/[email protected]
39
+ with :
40
+ token : ${{ secrets.GITHUB_TOKEN }}
41
+ body : |
42
+ 🎊 PR Preview has been successfully built and deployed to https://preview-pr-${{ steps.pr.outputs.id }}-element-ui.surge.sh
43
+ <img width="300" src="https://user-images.githubusercontent.com/507615/90250366-88233900-de6e-11ea-95a5-84f0762ffd39.png">
44
+ <!-- Sticky Pull Request Comment -->
45
+ body-include : ' <!-- Sticky Pull Request Comment -->'
46
+ number : ${{ steps.pr.outputs.id }}
47
+
48
+ - name : The job failed
49
+ if : ${{ failure() }}
50
+ uses :
actions-cool/[email protected]
51
+ with :
52
+ token : ${{ secrets.GITHUB_TOKEN }}
53
+ body : |
54
+ 😭 Deploy PR Preview failed.
55
+ <img width="300" src="https://user-images.githubusercontent.com/507615/90250824-4e066700-de6f-11ea-8230-600ecc3d6a6b.png">
56
+ <!-- Sticky Pull Request Comment -->
57
+ body-include : ' <!-- Sticky Pull Request Comment -->'
58
+ number : ${{ steps.pr.outputs.id }}
59
+
60
+ failed :
61
+ runs-on : ubuntu-latest
62
+ if : github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'failure'
63
+ steps :
64
+ - name : download pr artifact
65
+ uses : dawidd6/action-download-artifact@v2
66
+ with :
67
+ workflow : ${{ github.event.workflow_run.workflow_id }}
68
+ name : pr
69
+
70
+ - name : save PR id
71
+ id : pr
72
+ run : echo "::set-output name=id::$(<pr.txt)"
73
+
74
+ - name : The job failed
75
+ uses :
actions-cool/[email protected]
76
+ with :
77
+ token : ${{ secrets.GITHUB_TOKEN }}
78
+ body : |
79
+ 😭 Deploy PR Preview failed.
80
+ <img width="300" src="https://user-images.githubusercontent.com/507615/90250824-4e066700-de6f-11ea-8230-600ecc3d6a6b.png">
81
+ <!-- Sticky Pull Request Comment -->
82
+ body-include : ' <!-- Sticky Pull Request Comment -->'
83
+ number : ${{ steps.pr.outputs.id }}
0 commit comments