Skip to content

Commit fa76e11

Browse files
authored
Chore: fix CI (ElemeFE#21461)
* Create preview-build.yml * Chore: fix ci
1 parent d19304f commit fa76e11

File tree

3 files changed

+128
-27
lines changed

3 files changed

+128
-27
lines changed

.github/workflows/preview-build.yml

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Preview Build
2+
3+
on: pull_request
4+
5+
jobs:
6+
build:
7+
name: Build
8+
runs-on: ubuntu-latest
9+
env:
10+
PULL_REQUEST_NUMBER: ${{ github.event.number }}
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v2
14+
15+
- name: Setup node
16+
uses: actions/setup-node@v2
17+
with:
18+
node-version: '10.15.0'
19+
registry-url: https://registry.npmjs.com/
20+
21+
- name: Build
22+
run: npm run bootstrap && npm run deploy:build
23+
24+
25+
# share website dist
26+
- name: Upload artifact
27+
uses: actions/upload-artifact@v2
28+
with:
29+
name: docs
30+
path: examples/element-ui/
31+
retention-days: 1
32+
33+
# write pr.txt for share
34+
- name: Save pr number
35+
if: ${{ always() }}
36+
run: echo ${PULL_REQUEST_NUMBER} > ./pr.txt
37+
38+
# share pr number
39+
- name: Upload pr number
40+
if: ${{ always() }}
41+
uses: actions/upload-artifact@v2
42+
with:
43+
name: pr
44+
path: ./pr.txt
45+
retention-days: 1

.github/workflows/preview-deploy.yml

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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 }}

.github/workflows/preview.yml

-27
This file was deleted.

0 commit comments

Comments
 (0)