From 20e2009cac1f7c07dc6125cdf4276041793bdd7e Mon Sep 17 00:00:00 2001 From: xrkffgg Date: Wed, 24 Mar 2021 22:19:12 +0800 Subject: [PATCH] ci: update preview action (#8250) * Create preview-start.yml * Create preview-build.yml * Create preview-deploy.yml * Delete preview.yml * Update preview-deploy.yml * Update preview-build.yml * Update preview-deploy.yml * Update preview-deploy.yml * Update preview-deploy.yml * Update preview-build.yml * Update preview-deploy.yml --- .github/workflows/preview-build.yml | 38 ++++++++++++ .github/workflows/preview-deploy.yml | 89 ++++++++++++++++++++++++++++ .github/workflows/preview-start.yml | 18 ++++++ .github/workflows/preview.yml | 18 ------ 4 files changed, 145 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/preview-build.yml create mode 100644 .github/workflows/preview-deploy.yml create mode 100644 .github/workflows/preview-start.yml delete mode 100644 .github/workflows/preview.yml diff --git a/.github/workflows/preview-build.yml b/.github/workflows/preview-build.yml new file mode 100644 index 00000000..730f841b --- /dev/null +++ b/.github/workflows/preview-build.yml @@ -0,0 +1,38 @@ +name: Preview Build + +on: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + build-preview: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.head.sha }} + + - name: build + run: | + npm install + npm install umi-plugin-pro --save + npm run build + + - name: upload dist artifact + uses: actions/upload-artifact@v2 + with: + name: dist + path: dist/ + retention-days: 5 + + - name: Save PR number + if: ${{ always() }} + run: echo ${{ github.event.number }} > ./pr-id.txt + + - name: Upload PR number + if: ${{ always() }} + uses: actions/upload-artifact@v2 + with: + name: pr + path: ./pr-id.txt diff --git a/.github/workflows/preview-deploy.yml b/.github/workflows/preview-deploy.yml new file mode 100644 index 00000000..84757119 --- /dev/null +++ b/.github/workflows/preview-deploy.yml @@ -0,0 +1,89 @@ +name: Preview Deploy + +on: + workflow_run: + workflows: ["Preview Build"] + 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::$( + + + body-include: '' + number: ${{ steps.pr.outputs.id }} + + - name: The job failed + if: ${{ failure() }} + uses: actions-cool/maintain-one-comment@v1.2.1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + body: | + 😭 Deploy PR Preview failed. + + + + + body-include: '' + 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::$( + + + 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 00000000..f9ccd1df --- /dev/null +++ b/.github/workflows/preview-start.yml @@ -0,0 +1,18 @@ +name: Preview Start + +on: pull_request_target + +jobs: + preview: + runs-on: ubuntu-latest + steps: + - name: create + uses: actions-cool/maintain-one-comment@v1.2.1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + body: | + ⚡️ Deploying PR Preview... + + + + body-include: '' diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml deleted file mode 100644 index c2905031..00000000 --- a/.github/workflows/preview.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: 🔂 Surge PR Preview - -on: pull_request - -jobs: - preview: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: afc163/surge-preview@v1 - with: - surge_token: ${{ secrets.SURGE_TOKEN }} - github_token: ${{ secrets.GITHUB_TOKEN }} - build: | - npm install - npm install umi-plugin-pro --save - npm run build - dist: dist -- GitLab