|
| 1 | +name: Deploy Preview (with VRT/AAT reports) |
| 2 | +on: |
| 3 | + workflow_run: |
| 4 | + workflows: [CI] |
| 5 | + types: |
| 6 | + - completed |
| 7 | + |
| 8 | +concurrency: |
| 9 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 10 | + cancel-in-progress: true |
| 11 | + |
| 12 | +jobs: |
| 13 | + build: |
| 14 | + if: ${{ always() && github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.head_repository.full_name == 'primer/react' }} |
| 15 | + runs-on: ubuntu-latest |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: Checkout repository |
| 19 | + uses: actions/checkout@v4 |
| 20 | + - name: Set up Node.js |
| 21 | + uses: actions/setup-node@v4 |
| 22 | + with: |
| 23 | + node-version: 22 |
| 24 | + cache: 'npm' |
| 25 | + - name: Install dependencies |
| 26 | + run: npm ci |
| 27 | + - name: Build docs preview |
| 28 | + run: npm run build:docs:preview_with_reports |
| 29 | + - name: Download VRT reports (All flags enabled) |
| 30 | + uses: actions/download-artifact@v4 |
| 31 | + with: |
| 32 | + name: vrt-all-flags |
| 33 | + path: docs/public/vrt-all-flags |
| 34 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 35 | + repository: ${{ github.event.workflow_run.head_repository.full_name }} |
| 36 | + run-id: ${{ github.event.workflow_run.id }} |
| 37 | + - name: Download VRT reports (No flags enabled) |
| 38 | + uses: actions/download-artifact@v4 |
| 39 | + with: |
| 40 | + name: vrt-no-flag |
| 41 | + path: docs/public/vrt-no-flag |
| 42 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 43 | + repository: ${{ github.event.workflow_run.head_repository.full_name }} |
| 44 | + run-id: ${{ github.event.workflow_run.id }} |
| 45 | + - name: Download AAT reports (All flags enabled) |
| 46 | + uses: actions/download-artifact@v4 |
| 47 | + with: |
| 48 | + name: axe-all-flags |
| 49 | + path: docs/public/aat-all-flags |
| 50 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 51 | + repository: ${{ github.event.workflow_run.head_repository.full_name }} |
| 52 | + run-id: ${{ github.event.workflow_run.id }} |
| 53 | + - name: Download AAT reports (No flags enabled) |
| 54 | + uses: actions/download-artifact@v4 |
| 55 | + with: |
| 56 | + name: axe |
| 57 | + path: docs/public/aat-no-flag |
| 58 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 59 | + repository: ${{ github.event.workflow_run.head_repository.full_name }} |
| 60 | + run-id: ${{ github.event.workflow_run.id }} |
| 61 | + - uses: actions/upload-pages-artifact@v3 |
| 62 | + with: |
| 63 | + name: github-pages |
| 64 | + path: docs/public |
| 65 | + |
| 66 | + deploy-preview: |
| 67 | + if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.head_repository.full_name == 'primer/react' }} |
| 68 | + needs: build |
| 69 | + permissions: |
| 70 | + pages: write |
| 71 | + id-token: write |
| 72 | + environment: |
| 73 | + name: github-pages |
| 74 | + url: ${{ steps.deployment.outputs.page_url }} |
| 75 | + outputs: |
| 76 | + deployment_url: ${{ steps.deployment.outputs.page_url }} |
| 77 | + runs-on: ubuntu-latest |
| 78 | + steps: |
| 79 | + - name: Deploy to GitHub Pages |
| 80 | + id: deployment |
| 81 | + uses: actions/deploy-pages@v4 |
| 82 | + with: |
| 83 | + preview: true |
| 84 | + |
| 85 | + deploy-storybook: |
| 86 | + name: Preview Storybook |
| 87 | + if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.head_repository.full_name == 'primer/react' }} |
| 88 | + needs: deploy-preview |
| 89 | + permissions: |
| 90 | + deployments: write |
| 91 | + runs-on: ubuntu-latest |
| 92 | + steps: |
| 93 | + |
| 94 | + name: Create GitHub deployment for storybook |
| 95 | + id: storybook |
| 96 | + with: |
| 97 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 98 | + environment: storybook-preview-${{ github.event.workflow_run.event.number }} |
| 99 | + environment-url: '${{ needs.deploy-preview.outputs.deployment_url }}storybook' |
| 100 | + - name: Update storybook deployment status (success) |
| 101 | + if: success() |
| 102 | + |
| 103 | + with: |
| 104 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 105 | + environment-url: '${{ needs.deploy-preview.outputs.deployment_url }}storybook' |
| 106 | + state: 'success' |
| 107 | + deployment-id: ${{ steps.storybook.outputs.deployment_id }} |
| 108 | + - name: Update storybook deployment status (failure) |
| 109 | + if: failure() |
| 110 | + |
| 111 | + with: |
| 112 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 113 | + state: 'failure' |
| 114 | + deployment-id: ${{ steps.storybook.outputs.deployment_id }} |
| 115 | + |
| 116 | + deploy-vrt-no-flag: |
| 117 | + name: VRT (No flags enabled) |
| 118 | + if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.head_repository.full_name == 'primer/react' }} |
| 119 | + needs: [deploy-preview] |
| 120 | + permissions: |
| 121 | + deployments: write |
| 122 | + runs-on: ubuntu-latest |
| 123 | + steps: |
| 124 | + |
| 125 | + name: Create GitHub deployment for vrt-no-flag |
| 126 | + id: vrt-no-flag |
| 127 | + with: |
| 128 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 129 | + environment: vrt-no-flag-${{ github.event.workflow_run.head_branch }} |
| 130 | + environment-url: '${{ needs.deploy-preview.outputs.deployment_url }}vrt-no-flag' |
| 131 | + - name: Update vrt-no-flag deployment status (success) |
| 132 | + if: success() |
| 133 | + |
| 134 | + with: |
| 135 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 136 | + environment-url: '${{ needs.deploy-preview.outputs.deployment_url }}vrt-no-flag' |
| 137 | + state: 'success' |
| 138 | + deployment-id: ${{ steps.vrt-no-flag.outputs.deployment_id }} |
| 139 | + - name: Update vrt-no-flag deployment status (failure) |
| 140 | + if: failure() |
| 141 | + |
| 142 | + with: |
| 143 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 144 | + state: 'failure' |
| 145 | + deployment-id: ${{ steps.vrt-no-flag.outputs.deployment_id }} |
| 146 | + |
| 147 | + deploy-vrt-all-flags: |
| 148 | + name: VRT (All flags enabled) |
| 149 | + if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.head_repository.full_name == 'primer/react' }} |
| 150 | + needs: deploy-preview |
| 151 | + permissions: |
| 152 | + deployments: write |
| 153 | + runs-on: ubuntu-latest |
| 154 | + steps: |
| 155 | + |
| 156 | + name: Create GitHub deployment for vrt-all-flags |
| 157 | + id: vrt-all-flags |
| 158 | + with: |
| 159 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 160 | + environment: vrt-all-flags-${{ github.event.workflow_run.event.number }} |
| 161 | + environment-url: '${{ needs.deploy-preview.outputs.deployment_url }}vrt-all-flags' |
| 162 | + - name: Update vrt-all-flags deployment status (success) |
| 163 | + if: success() |
| 164 | + |
| 165 | + with: |
| 166 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 167 | + environment-url: '${{ needs.deploy-preview.outputs.deployment_url }}vrt-all-flags' |
| 168 | + state: 'success' |
| 169 | + deployment-id: ${{ steps.vrt-all-flags.outputs.deployment_id }} |
| 170 | + - name: Update vrt-all-flags deployment status (failure) |
| 171 | + if: failure() |
| 172 | + |
| 173 | + with: |
| 174 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 175 | + state: 'failure' |
| 176 | + deployment-id: ${{ steps.vrt-all-flags.outputs.deployment_id }} |
| 177 | + |
| 178 | + deploy-aat-no-flag: |
| 179 | + name: AAT (No flags enabled) |
| 180 | + if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.head_repository.full_name == 'primer/react' }} |
| 181 | + needs: deploy-preview |
| 182 | + permissions: |
| 183 | + deployments: write |
| 184 | + runs-on: ubuntu-latest |
| 185 | + steps: |
| 186 | + |
| 187 | + name: Create GitHub deployment for aat-no-flag |
| 188 | + id: aat-no-flag |
| 189 | + with: |
| 190 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 191 | + environment: aat-no-flag-${{ github.event.workflow_run.event.number }} |
| 192 | + environment-url: '${{ needs.deploy-preview.outputs.deployment_url }}aat-no-flag' |
| 193 | + - name: Update aat-no-flag deployment status (success) |
| 194 | + if: success() |
| 195 | + |
| 196 | + with: |
| 197 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 198 | + environment-url: '${{ needs.deploy-preview.outputs.deployment_url }}aat-no-flag' |
| 199 | + state: 'success' |
| 200 | + deployment-id: ${{ steps.aat-no-flag.outputs.deployment_id }} |
| 201 | + - name: Update aat-no-flag deployment status (failure) |
| 202 | + if: failure() |
| 203 | + |
| 204 | + with: |
| 205 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 206 | + state: 'failure' |
| 207 | + deployment-id: ${{ steps.aat-no-flag.outputs.deployment_id }} |
| 208 | + |
| 209 | + deploy-aat-all-flags: |
| 210 | + name: AAT (All flags enabled) |
| 211 | + if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.head_repository.full_name == 'primer/react' }} |
| 212 | + needs: deploy-preview |
| 213 | + permissions: |
| 214 | + deployments: write |
| 215 | + runs-on: ubuntu-latest |
| 216 | + steps: |
| 217 | + |
| 218 | + name: Create GitHub deployment for aat-all-flags |
| 219 | + id: aat-all-flags |
| 220 | + with: |
| 221 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 222 | + environment: aat-all-flags-${{ github.event.workflow_run.event.number }} |
| 223 | + environment-url: '${{ needs.deploy-preview.outputs.deployment_url }}aat-all-flags' |
| 224 | + - name: Update aat-all-flags deployment status (success) |
| 225 | + if: success() |
| 226 | + |
| 227 | + with: |
| 228 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 229 | + environment-url: '${{ needs.deploy-preview.outputs.deployment_url }}aat-all-flags' |
| 230 | + state: 'success' |
| 231 | + deployment-id: ${{ steps.aat-all-flags.outputs.deployment_id }} |
| 232 | + - name: Update aat-all-flags deployment status (failure) |
| 233 | + if: failure() |
| 234 | + |
| 235 | + with: |
| 236 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 237 | + state: 'failure' |
| 238 | + deployment-id: ${{ steps.aat-all-flags.outputs.deployment_id }} |
0 commit comments