-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from Tencent/hotfix/pr-action
Hotfix/pr action
- Loading branch information
Showing
3 changed files
with
97 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
name: PREVIEW_PUBLISH | ||
|
||
on: | ||
workflow_run: | ||
workflows: ['MAIN_PULL_REQUEST'] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
success: | ||
runs-on: ubuntu-latest | ||
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' | ||
steps: | ||
- name: download pr artifact | ||
uses: dawidd6/action-download-artifact@v2 | ||
with: | ||
workflow: ${{ github.event.workflow_run.workflow_id }} | ||
name: pr | ||
- name: save PR id | ||
id: pr | ||
run: echo "::set-output name=id::$(<pr-id.txt)" | ||
- name: download _site artifact | ||
uses: dawidd6/action-download-artifact@v2 | ||
with: | ||
workflow: ${{ github.event.workflow_run.workflow_id }} | ||
workflow_conclusion: success | ||
name: _site | ||
- run: | | ||
unzip _site.zip | ||
- name: Upload surge service and generate preview URL | ||
id: deploy | ||
run: | | ||
export DEPLOY_DOMAIN=https://preview-pr${{ steps.pr.outputs.id }}-tdesign-vue.surge.sh | ||
npx surge --project ./_site --domain $DEPLOY_DOMAIN --token ${{ secrets.TDESIGN_SURGE_TOKEN }} | ||
echo the preview URL is $DEPLOY_DOMAIN | ||
- name: update status comment | ||
uses: actions-cool/maintain-one-comment@v1.1.0 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
body: | | ||
PR 预览产物在 https://preview-pr${{ steps.pr.outputs.id }}-tdesign-vue.surge.sh | ||
number: ${{ steps.pr.outputs.id }} | ||
- run: | | ||
rm -rf _site/ | ||
- name: The job failed | ||
if: ${{ failure() }} | ||
uses: actions-cool/maintain-one-comment@v1.1.0 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
body: | | ||
PR 预览生成失败。 | ||
number: ${{ steps.pr.outputs.id }} | ||
|
||
failed: | ||
runs-on: ubuntu-latest | ||
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'failure' | ||
steps: | ||
- name: download pr artifact | ||
uses: dawidd6/action-download-artifact@v2 | ||
with: | ||
workflow: ${{ github.event.workflow_run.workflow_id }} | ||
name: pr | ||
- name: save PR id | ||
id: pr | ||
run: echo "::set-output name=id::$(<pr-id.txt)" | ||
- name: The job failed | ||
uses: actions-cool/maintain-one-comment@v1.1.0 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
body: | | ||
Deploy PR Preview failed. | ||
number: ${{ steps.pr.outputs.id }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters