preview-deploy.yml 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. name: Preview Deploy
  2. on:
  3. workflow_run:
  4. workflows: ["Preview Build"]
  5. types:
  6. - completed
  7. jobs:
  8. success:
  9. runs-on: ubuntu-latest
  10. if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
  11. steps:
  12. - name: download pr artifact
  13. uses: dawidd6/action-download-artifact@v2
  14. with:
  15. workflow: ${{ github.event.workflow_run.workflow_id }}
  16. name: pr
  17. - name: save PR id
  18. id: pr
  19. run: echo "::set-output name=id::$(<pr-id.txt)"
  20. - name: download dist artifact
  21. uses: dawidd6/action-download-artifact@v2
  22. with:
  23. workflow: ${{ github.event.workflow_run.workflow_id }}
  24. workflow_conclusion: success
  25. name: dist
  26. - name: upload surge service
  27. id: deploy
  28. run: |
  29. export DEPLOY_DOMAIN=https://ant-design-pro-preview-pr-${{ steps.pr.outputs.id }}.surge.sh
  30. npx surge --project ./ --domain $DEPLOY_DOMAIN --token ${{ secrets.SURGE_TOKEN }}
  31. - name: update status comment
  32. uses: actions-cool/maintain-one-comment@v1.2.1
  33. with:
  34. token: ${{ secrets.GITHUB_TOKEN }}
  35. body: |
  36. 🎊 PR Preview has been successfully built and deployed to https://ant-design-pro-preview-pr-${{ steps.pr.outputs.id }}.surge.sh
  37. <img width="300" src="https://user-images.githubusercontent.com/507615/90250366-88233900-de6e-11ea-95a5-84f0762ffd39.png">
  38. <!-- Sticky Pull Request Comment -->
  39. body-include: '<!-- Sticky Pull Request Comment -->'
  40. number: ${{ steps.pr.outputs.id }}
  41. - name: The job failed
  42. if: ${{ failure() }}
  43. uses: actions-cool/maintain-one-comment@v1.2.1
  44. with:
  45. token: ${{ secrets.GITHUB_TOKEN }}
  46. body: |
  47. 😭 Deploy PR Preview failed.
  48. <img width="300" src="https://user-images.githubusercontent.com/507615/90250824-4e066700-de6f-11ea-8230-600ecc3d6a6b.png">
  49. <!-- Sticky Pull Request Comment -->
  50. body-include: '<!-- Sticky Pull Request Comment -->'
  51. number: ${{ steps.pr.outputs.id }}
  52. failed:
  53. runs-on: ubuntu-latest
  54. if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'failure'
  55. steps:
  56. - name: download pr artifact
  57. uses: dawidd6/action-download-artifact@v2
  58. with:
  59. workflow: ${{ github.event.workflow_run.workflow_id }}
  60. name: pr
  61. - name: save PR id
  62. id: pr
  63. run: echo "::set-output name=id::$(<pr-id.txt)"
  64. - name: The job failed
  65. uses: actions-cool/maintain-one-comment@v1.2.1
  66. with:
  67. token: ${{ secrets.GITHUB_TOKEN }}
  68. body: |
  69. 😭 Deploy PR Preview failed.
  70. <img width="300" src="https://user-images.githubusercontent.com/507615/90250824-4e066700-de6f-11ea-8230-600ecc3d6a6b.png">
  71. <!-- Sticky Pull Request Comment -->
  72. body-include: '<!-- Sticky Pull Request Comment -->'
  73. number: ${{ steps.pr.outputs.id }}