mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-03 11:47:48 +08:00
a2be1973ea
* chore(project): use github workflow for website preview * chore: update PULL_REQUEST_NUMBER * fix: typo * chore: add pull_request for test * fix: json format * fix: add robot test * fix: update request * chore: update var * chore: update var & remove test * chore: improve workflow * chore: upgrade workflow
81 lines
2.8 KiB
YAML
81 lines
2.8 KiB
YAML
# This workflow runs on target, so there is no need to worry about secrets
|
|
name: Website Preview Deploy
|
|
|
|
on:
|
|
workflow_run:
|
|
workflows: ['Website Preview']
|
|
types: [completed]
|
|
|
|
jobs:
|
|
# Build successfully, start deployment
|
|
on-success:
|
|
name: Build successfully
|
|
runs-on: ubuntu-latest
|
|
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
|
steps:
|
|
- name: Download pr number
|
|
uses: dawidd6/action-download-artifact@v2
|
|
with:
|
|
workflow: ${{ github.event.workflow_run.workflow_id }}
|
|
name: pr
|
|
|
|
- name: Output pr number
|
|
id: pr
|
|
run: echo "::set-output name=id::$(<pr.txt)"
|
|
|
|
- name: Download artifact
|
|
uses: dawidd6/action-download-artifact@v2
|
|
with:
|
|
workflow: ${{ github.event.workflow_run.workflow_id }}
|
|
workflow_conclusion: success
|
|
name: website
|
|
|
|
- name: Deploy Site
|
|
run: |
|
|
export DEPLOY_DOMAIN=https://preview-${PULL_REQUEST_NUMBER}-element-plus.surge.sh
|
|
echo "Deploy to $DEPLOY_DOMAIN"
|
|
npx surge --project ./ --domain $DEPLOY_DOMAIN --token $SURGE_TOKEN
|
|
env:
|
|
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
|
|
PULL_REQUEST_NUMBER: ${{ steps.pr.outputs.id }}
|
|
|
|
- name: Deploy has succeeded
|
|
if: ${{ success() }}
|
|
run: |
|
|
export DEPLOY_DOMAIN=https://preview-${PULL_REQUEST_NUMBER}-element-plus.surge.sh
|
|
curl -X POST ${BOT_URL} -H 'Content-Type:application/json' --data-raw '{"botAction":"Preview", "pr":'${PULL_REQUEST_NUMBER}', "url":"'${DEPLOY_DOMAIN}'"}'
|
|
env:
|
|
BOT_URL: ${{ secrets.BOT_URL }}
|
|
PULL_REQUEST_NUMBER: ${{ steps.pr.outputs.id }}
|
|
|
|
- name: Deploy has failed
|
|
if: ${{ failure() }}
|
|
run: |
|
|
curl -X POST ${BOT_URL} -H 'Content-Type:application/json' --data-raw '{"status":"error", "botAction":"Preview", "pr":'${PULL_REQUEST_NUMBER}'}'
|
|
env:
|
|
BOT_URL: ${{ secrets.BOT_URL }}
|
|
PULL_REQUEST_NUMBER: ${{ steps.pr.outputs.id }}
|
|
|
|
# Build failed, update comment
|
|
on-failure:
|
|
name: Build failed
|
|
runs-on: ubuntu-latest
|
|
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
|
|
steps:
|
|
- name: Download pr number
|
|
uses: dawidd6/action-download-artifact@v2
|
|
with:
|
|
workflow: ${{ github.event.workflow_run.workflow_id }}
|
|
name: pr
|
|
|
|
- name: Output pr number
|
|
id: pr
|
|
run: echo "::set-output name=id::$(<pr.txt)"
|
|
|
|
- name: Update comment
|
|
run: |
|
|
curl -X POST ${BOT_URL} -H 'Content-Type:application/json' --data-raw '{"status":"error", "botAction":"Preview", "pr":'${PULL_REQUEST_NUMBER}'}'
|
|
env:
|
|
BOT_URL: ${{ secrets.BOT_URL }}
|
|
PULL_REQUEST_NUMBER: ${{ steps.pr.outputs.id }}
|