|
4 | 4 | push: |
5 | 5 | branches: |
6 | 6 | - main |
| 7 | + workflow_dispatch: |
| 8 | + pull_request: |
7 | 9 |
|
8 | 10 | jobs: |
9 | | - deploy: |
| 11 | + deploy-main: |
10 | 12 | runs-on: ubuntu-latest |
11 | 13 | permissions: |
12 | 14 | contents: write |
13 | 15 | concurrency: |
14 | 16 | group: ${{ github.workflow }}-${{ github.ref }} |
| 17 | + cancel-in-progress: true |
| 18 | + if: ${{ github.ref == 'refs/heads/main' }} |
| 19 | + |
15 | 20 | steps: |
16 | 21 | - uses: actions/checkout@v4 |
17 | 22 |
|
18 | | - # Build documentation repo |
19 | 23 | - uses: actions/setup-node@v4 |
20 | 24 | with: |
21 | 25 | node-version: lts/* |
|
35 | 39 | github_token: ${{ secrets.GITHUB_TOKEN }} |
36 | 40 | publish_dir: ./build |
37 | 41 | cname: revisit.dev |
| 42 | + keep_files: true |
| 43 | + |
| 44 | + deploy-preview: |
| 45 | + runs-on: ubuntu-latest |
| 46 | + permissions: |
| 47 | + contents: write |
| 48 | + pull-requests: write |
| 49 | + concurrency: |
| 50 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 51 | + cancel-in-progress: true |
| 52 | + if: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/dev' }} |
| 53 | + |
| 54 | + steps: |
| 55 | + - name: Comment on PR |
| 56 | + uses: hasura/comment-progress@v2.2.0 |
| 57 | + with: |
| 58 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 59 | + repository: ${{ github.repository }} |
| 60 | + number: ${{ github.event.number }} |
| 61 | + id: deploy-preview |
| 62 | + message: "Starting deployment of preview ⏳..." |
| 63 | + |
| 64 | + - uses: actions/checkout@v4 |
| 65 | + |
| 66 | + - uses: actions/setup-node@v4 |
| 67 | + with: |
| 68 | + node-version: lts/* |
| 69 | + cache: 'yarn' |
| 70 | + |
| 71 | + - run: yarn install --immutable |
| 72 | + |
| 73 | + - name: Build with PR base path |
| 74 | + run: yarn build |
| 75 | + env: |
| 76 | + DOCUSAURUS_BASE_URL: "/PR${{ github.event.number }}/" |
| 77 | + |
| 78 | + - name: Push PR deploy preview |
| 79 | + uses: peaceiris/actions-gh-pages@v3 |
| 80 | + with: |
| 81 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 82 | + publish_dir: ./build |
| 83 | + destination_dir: "PR${{ github.event.number }}" |
| 84 | + |
| 85 | + - name: Update comment |
| 86 | + uses: hasura/comment-progress@v2.2.0 |
| 87 | + with: |
| 88 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 89 | + repository: ${{ github.repository }} |
| 90 | + number: ${{ github.event.number }} |
| 91 | + id: deploy-preview |
| 92 | + message: "A preview of ${{ github.event.after }} is uploaded and can be seen here:\n\n ✨ https://revisit.dev/PR${{ github.event.number }} ✨\n\nChanges may take a few minutes to propagate." |
0 commit comments