# This workflow runs on target, so there is no need to worry about secrets name: PR Docs Deploy on: workflow_run: workflows: ['PR Docs Build'] 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.id }} run_id: ${{ github.event.workflow_run.id }} name: pr - name: Output pr number id: pr run: echo "id=$(> $GITHUB_OUTPUT - name: Download artifact uses: dawidd6/action-download-artifact@v2 with: workflow: ${{ github.event.workflow.id }} run_id: ${{ github.event.workflow_run.id }} name: docs - 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: Comment preview link if: ${{ success() }} uses: actions-cool/maintain-one-comment@v3.1.1 with: token: ${{ secrets.GITHUB_TOKEN }} body: | [](https://preview-${{ steps.pr.outputs.id }}-element-plus.surge.sh) body-include: '' number: ${{ steps.pr.outputs.id }} - name: Comment playground link if: ${{ success() }} uses: actions-cool/maintain-one-comment@v3.1.1 with: token: ${{ secrets.GITHUB_TOKEN }} body: | 🧪 Playground Preview: https://element-plus.run/?pr=${{ steps.pr.outputs.id }} Please comment the example via this playground if needed. body-include: '' number: ${{ steps.pr.outputs.id }} - name: Deploy has failed if: ${{ failure() }} uses: actions-cool/maintain-one-comment@v3.1.1 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: 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.id }} run_id: ${{ github.event.workflow_run.id }} name: pr - name: Output pr number id: pr run: echo "id=$(> $GITHUB_OUTPUT - name: Deploy has failed uses: actions-cool/maintain-one-comment@v3.1.1 with: token: ${{ secrets.GITHUB_TOKEN }} body: | [](https://preview-${{ steps.pr.outputs.id }}-element-plus.surge.sh) body-include: '' number: ${{ steps.pr.outputs.id }}