|
| 1 | +name: Preview CLI Package |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: |
| 6 | + - opened |
| 7 | + - synchronize |
| 8 | + - reopened |
| 9 | + |
| 10 | +concurrency: |
| 11 | + group: preview-cli-package-${{ github.event.pull_request.number }} |
| 12 | + cancel-in-progress: true |
| 13 | + |
| 14 | +jobs: |
| 15 | + preview: |
| 16 | + if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} |
| 17 | + runs-on: ubuntu-latest |
| 18 | + permissions: |
| 19 | + contents: read |
| 20 | + pull-requests: write |
| 21 | + |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd |
| 24 | + with: |
| 25 | + ref: ${{ github.event.pull_request.head.sha }} |
| 26 | + persist-credentials: false |
| 27 | + |
| 28 | + - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 |
| 29 | + with: |
| 30 | + version: 10.30.0 |
| 31 | + |
| 32 | + - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e |
| 33 | + with: |
| 34 | + node-version: 24 |
| 35 | + cache: pnpm |
| 36 | + |
| 37 | + - name: Install dependencies |
| 38 | + run: pnpm install --frozen-lockfile |
| 39 | + |
| 40 | + - name: Resolve preview version |
| 41 | + id: cli_version |
| 42 | + run: | |
| 43 | + node scripts/resolve-cli-version.mjs pr \ |
| 44 | + --sha '${{ github.event.pull_request.head.sha }}' \ |
| 45 | + --pr-number '${{ github.event.pull_request.number }}' >> "$GITHUB_OUTPUT" |
| 46 | +
|
| 47 | + - name: Run focused CLI tests |
| 48 | + id: cli_tests |
| 49 | + run: pnpm --filter @prisma/cli test |
| 50 | + |
| 51 | + - name: Build CLI package |
| 52 | + id: cli_build |
| 53 | + run: pnpm --filter @prisma/cli build |
| 54 | + |
| 55 | + - name: Prepare staged preview package |
| 56 | + id: prepare_preview |
| 57 | + run: node scripts/prepare-cli-publish.mjs .publish/cli --version '${{ steps.cli_version.outputs.version }}' |
| 58 | + |
| 59 | + - name: Publish installable PR preview |
| 60 | + id: publish_preview |
| 61 | + continue-on-error: ${{ vars.CLI_PR_PREVIEW_REQUIRED != 'true' }} |
| 62 | + run: pnpm exec pkg-pr-new publish --bin --comment=update .publish/cli |
| 63 | + |
| 64 | + - name: Summarize PR preview publish |
| 65 | + if: ${{ always() }} |
| 66 | + run: | |
| 67 | + { |
| 68 | + echo "## Preview CLI Package" |
| 69 | + echo |
| 70 | + echo "- Version: \`${{ steps.cli_version.outputs.version }}\`" |
| 71 | + echo "- CLI tests: \`${{ steps.cli_tests.outcome || 'skipped' }}\`" |
| 72 | + echo "- Build: \`${{ steps.cli_build.outcome || 'skipped' }}\`" |
| 73 | + echo "- Package staging: \`${{ steps.prepare_preview.outcome || 'skipped' }}\`" |
| 74 | + echo "- pkg.pr.new publish: \`${{ steps.publish_preview.outcome || 'skipped' }}\`" |
| 75 | + PUBLISH_OUTCOME="${{ steps.publish_preview.outcome || 'skipped' }}" |
| 76 | + if [ "${PUBLISH_OUTCOME}" != "success" ]; then |
| 77 | + echo |
| 78 | + echo "pkg.pr.new publishing is best-effort while \`CLI_PR_PREVIEW_REQUIRED\` is not \`true\`. If this failed, confirm the pkg.pr.new GitHub App is installed for this repository and rerun the workflow." |
| 79 | + fi |
| 80 | + } >> "$GITHUB_STEP_SUMMARY" |
0 commit comments