|
48 | 48 | FOLDER: "${{ env.SITE_DIR }}"
|
49 | 49 | BRANCH: "gh-pages"
|
50 | 50 | COMMIT_MESSAGE: "[CI] Publish Documentation for ${{ github.sha }}"
|
| 51 | + |
| 52 | + deploy_preview: |
| 53 | + env: |
| 54 | + PR_PATH: pull-${{ github.event.number }} |
| 55 | + runs-on: [ ubuntu-latest ] |
| 56 | + needs: [ build_site ] |
| 57 | + name: "Deploy preview for PR" |
| 58 | + if: github.event_name == 'pull_request' |
| 59 | + steps: |
| 60 | + - name: Comment on PR |
| 61 | + |
| 62 | + with: |
| 63 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 64 | + repository: ${{ github.repository }} |
| 65 | + number: ${{ github.event.number }} |
| 66 | + id: deploy-preview |
| 67 | + message: "Starting deployment of preview ⏳..." |
| 68 | + |
| 69 | + - name: Set base URL for preview |
| 70 | + run: echo "BASE_URL=https://${{ github.event.organization.name }}.github.io/${{ github.event.repository.name }}/${{ env.PR_PATH }}/" >> $GITHUB_ENV |
| 71 | + |
| 72 | + - name: Checkout |
| 73 | + uses: actions/checkout@v4 |
| 74 | + - name: Download generated site |
| 75 | + uses: actions/download-artifact@v4 |
| 76 | + with: |
| 77 | + name: site |
| 78 | + path: "${{ github.workspace }}/${{ env.SITE_DIR }}" |
| 79 | + - name: Deploy PR preview |
| 80 | + |
| 81 | + with: |
| 82 | + GITHUB_TOKEN: "${{ github.token}}" |
| 83 | + FOLDER: "${{ env.SITE_DIR }}/${{ env.PR_PATH }}" |
| 84 | + BRANCH: "gh-pages" |
| 85 | + COMMIT_MESSAGE: "[CI] Publish Preview for PR #${{ github.event.number }}" |
| 86 | + |
| 87 | + - name: Update comment |
| 88 | + |
| 89 | + with: |
| 90 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 91 | + repository: ${{ github.repository }} |
| 92 | + number: ${{ github.event.number }} |
| 93 | + id: deploy-preview |
| 94 | + message: | |
| 95 | + A preview of ${{ github.event.after }} is uploaded and can be seen here: |
| 96 | + |
| 97 | + ✨ ${{ env.BASE_URL }} ✨ |
| 98 | + |
| 99 | + Changes may take a few minutes to propagate. |
| 100 | + |
| 101 | + The source is here: https://github.com/${{ github.repository }}/tree/gh-pages/${{ env.PR_PATH }}/ |
0 commit comments