86133 | aaa3f5d | 2025-04-20 21:33:29 +0800 | [diff] [blame^] | 1 | name: Preview Deploy |
| 2 | |
| 3 | on: |
| 4 | workflow_run: |
| 5 | workflows: ['Preview Build'] |
| 6 | types: |
| 7 | - completed |
| 8 | |
| 9 | permissions: |
| 10 | contents: read |
| 11 | |
| 12 | jobs: |
| 13 | success: |
| 14 | permissions: |
| 15 | actions: read # for dawidd6/action-download-artifact to query and download artifacts |
| 16 | issues: write # for actions-cool/maintain-one-comment to modify or create issue comments |
| 17 | pull-requests: write # for actions-cool/maintain-one-comment to modify or create PR comments |
| 18 | runs-on: ubuntu-latest |
| 19 | if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' |
| 20 | steps: |
| 21 | - name: download pr artifact |
| 22 | uses: dawidd6/action-download-artifact@v2 |
| 23 | with: |
| 24 | workflow: ${{ github.event.workflow_run.workflow_id }} |
| 25 | name: pr |
| 26 | |
| 27 | - name: save PR id |
| 28 | id: pr |
| 29 | run: echo "::set-output name=id::$(<pr-id.txt)" |
| 30 | |
| 31 | - name: download dist artifact |
| 32 | uses: dawidd6/action-download-artifact@v2 |
| 33 | with: |
| 34 | workflow: ${{ github.event.workflow_run.workflow_id }} |
| 35 | workflow_conclusion: success |
| 36 | name: dist |
| 37 | |
| 38 | - name: upload surge service |
| 39 | id: deploy |
| 40 | run: | |
| 41 | export DEPLOY_DOMAIN=https://ant-design-pro-preview-pr-${{ steps.pr.outputs.id }}.surge.sh |
| 42 | npx surge --project ./ --domain $DEPLOY_DOMAIN --token ${{ secrets.SURGE_TOKEN }} |
| 43 | |
| 44 | - name: update status comment |
| 45 | uses: actions-cool/maintain-one-comment@v1.2.1 |
| 46 | with: |
| 47 | token: ${{ secrets.GITHUB_TOKEN }} |
| 48 | body: | |
| 49 | 🎊 PR Preview has been successfully built and deployed to https://ant-design-pro-preview-pr-${{ steps.pr.outputs.id }}.surge.sh |
| 50 | |
| 51 | <img width="300" src="https://user-images.githubusercontent.com/507615/90250366-88233900-de6e-11ea-95a5-84f0762ffd39.png"> |
| 52 | |
| 53 | <!-- Sticky Pull Request Comment --> |
| 54 | body-include: '<!-- Sticky Pull Request Comment -->' |
| 55 | number: ${{ steps.pr.outputs.id }} |
| 56 | |
| 57 | - name: The job failed |
| 58 | if: ${{ failure() }} |
| 59 | uses: actions-cool/maintain-one-comment@v1.2.1 |
| 60 | with: |
| 61 | token: ${{ secrets.GITHUB_TOKEN }} |
| 62 | body: | |
| 63 | 😠Deploy PR Preview failed. |
| 64 | |
| 65 | <img width="300" src="https://user-images.githubusercontent.com/507615/90250824-4e066700-de6f-11ea-8230-600ecc3d6a6b.png"> |
| 66 | |
| 67 | <!-- Sticky Pull Request Comment --> |
| 68 | body-include: '<!-- Sticky Pull Request Comment -->' |
| 69 | number: ${{ steps.pr.outputs.id }} |
| 70 | |
| 71 | failed: |
| 72 | permissions: |
| 73 | actions: read # for dawidd6/action-download-artifact to query and download artifacts |
| 74 | issues: write # for actions-cool/maintain-one-comment to modify or create issue comments |
| 75 | pull-requests: write # for actions-cool/maintain-one-comment to modify or create PR comments |
| 76 | runs-on: ubuntu-latest |
| 77 | if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'failure' |
| 78 | steps: |
| 79 | - name: download pr artifact |
| 80 | uses: dawidd6/action-download-artifact@v2 |
| 81 | with: |
| 82 | workflow: ${{ github.event.workflow_run.workflow_id }} |
| 83 | name: pr |
| 84 | |
| 85 | - name: save PR id |
| 86 | id: pr |
| 87 | run: echo "::set-output name=id::$(<pr-id.txt)" |
| 88 | |
| 89 | - name: The job failed |
| 90 | uses: actions-cool/maintain-one-comment@v1.2.1 |
| 91 | with: |
| 92 | token: ${{ secrets.GITHUB_TOKEN }} |
| 93 | body: | |
| 94 | 😠Deploy PR Preview failed. |
| 95 | |
| 96 | <img width="300" src="https://user-images.githubusercontent.com/507615/90250824-4e066700-de6f-11ea-8230-600ecc3d6a6b.png"> |
| 97 | |
| 98 | <!-- Sticky Pull Request Comment --> |
| 99 | body-include: '<!-- Sticky Pull Request Comment -->' |
| 100 | number: ${{ steps.pr.outputs.id }} |