From 21d41aed87f8a4e23992f6cdb366659bb0bf10f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90?= Date: Sat, 11 Dec 2021 00:27:29 +0800 Subject: [PATCH] ci: refactor pr preview alert (#4781) --- .github/workflows/preview-deploy.yml | 42 +++++++++++++++++----------- .github/workflows/preview-start.yml | 16 +++++++++++ 2 files changed, 41 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/preview-start.yml diff --git a/.github/workflows/preview-deploy.yml b/.github/workflows/preview-deploy.yml index 729aeb131a..c2b6b37a57 100644 --- a/.github/workflows/preview-deploy.yml +++ b/.github/workflows/preview-deploy.yml @@ -42,20 +42,25 @@ jobs: - 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 }} + uses: actions-cool/maintain-one-comment@v1.1.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + body: | + [](https://preview-${{ steps.pr.outputs.id }}-element-plus.surge.sh) + + body-include: '' + 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 }} + uses: actions-cool/maintain-one-comment@v1.1.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + body: | + [](https://preview-${{ steps.pr.outputs.id }}-element-plus.surge.sh) + + body-include: '' + number: ${{ steps.pr.outputs.id }} # Build failed, update comment on-failure: @@ -74,9 +79,12 @@ jobs: id: pr run: echo "::set-output name=id::$(](https://preview-${{ steps.pr.outputs.id }}-element-plus.surge.sh) + + body-include: '' + number: ${{ steps.pr.outputs.id }} diff --git a/.github/workflows/preview-start.yml b/.github/workflows/preview-start.yml new file mode 100644 index 0000000000..1a21203968 --- /dev/null +++ b/.github/workflows/preview-start.yml @@ -0,0 +1,16 @@ +name: Preview Start + +on: pull_request_target + +jobs: + preview: + runs-on: ubuntu-latest + steps: + - name: create + uses: actions-cool/maintain-one-comment@v1.1.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + body: | + + + body-include: ''