-
Notifications
You must be signed in to change notification settings - Fork 59
feat(ci): add pkg.pr.new preview releases #415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| name: Publish Preview | ||
|
|
||
| on: | ||
| pull_request: | ||
| workflow_dispatch: | ||
|
|
||
| env: | ||
| NX_BRANCH: ${{ github.event.number }} | ||
| NX_RUN_GROUP: ${{ github.run_id }} | ||
|
|
||
| jobs: | ||
| publish-preview: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Use Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 22.x | ||
|
|
||
| - name: Setup | ||
| uses: ./.github/actions/setup-step | ||
|
|
||
| - name: Build | ||
| run: yarn nx run-many --target=build --all | ||
|
|
||
| - name: Publish Preview | ||
| run: npx pkg-pr-new publish './dist/packages/*' | ||
|
Comment on lines
+12
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # Check for pkg-pr-new usage in the codebase
find . -type f \( -name "*.yml" -o -name "*.yaml" -o -name "*.json" -o -name "*.md" \) | head -20 | xargs grep -l "pkg-pr-new" 2>/dev/null || echo "No matches found in main files"Repository: TriPSs/nestjs-query Length of output: 182 🏁 Script executed: # List all workflow files to see patterns
ls -la .github/workflows/ 2>/dev/null || echo "No workflows directory found"Repository: TriPSs/nestjs-query Length of output: 182 🏁 Script executed: # Check other workflows for permissions declarations
find .github/workflows -name "*.yml" -o -name "*.yaml" | head -10 | xargs grep -B5 -A2 "permissions:" 2>/dev/null || echo "No permissions declarations found"Repository: TriPSs/nestjs-query Length of output: 182 🏁 Script executed: # Check package.json for pkg-pr-new
cat package.json 2>/dev/null | grep -A5 -B5 "pkg-pr-new" || echo "Not found in package.json"Repository: TriPSs/nestjs-query Length of output: 182 🏁 Script executed: # Check if there's any documentation about pkg-pr-new setup
find . -name "*.md" -type f | xargs grep -l "pkg-pr-new" 2>/dev/null || echo "No markdown documentation found"Repository: TriPSs/nestjs-query Length of output: 182 🌐 Web query:
💡 Result: Short answer — pkg.pr.new uses a GitHub App + the workflow GITHUB_TOKEN. Required auth/permissions are:
Common minimal permissions to grant the workflow (examples supported by the repo + GitHub docs):
Example permissions block (put in your workflow if you want explicit minimal permissions): References
If you want, tell me the exact workflow you’re using and I’ll produce a ready-to-copy permissions block. Add explicit permissions for pkg-pr-new workflow. The workflow does not declare explicit permissions. The pkg-pr-new tool requires the GitHub App to be installed on the repository and specific token scopes to function correctly. The workflow should declare explicit permissions rather than relying on default token scopes. Add the following permissions block at the job level: publish-preview:
runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ pull-requests: write
+ issues: write
steps:Ensure the pkg.pr.new GitHub App is installed on the repository (see https://github.com/apps/pkg-pr-new). The workflow will use the default GITHUB_TOKEN, which is sufficient for pkg-pr-new's operations once the App is installed. 🤖 Prompt for AI Agents |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: TriPSs/nestjs-query
Length of output: 182
🌐 Web query:
GitHub Actions github.event.number workflow_dispatch availability💡 Result:
Short answer: No — github.event.number is not provided for workflow_dispatch. The workflow_dispatch webhook/payload contains inputs, ref, repository, sender, workflow, etc., but it has no top-level "number" field (that field appears on events like pull_request or issues). See the workflow_dispatch payload spec and an example payload. [1][2]
If you need an identifier in workflow_dispatch, pass it as an input (or include it in repository_dispatch client_payload) and read it via github.event.inputs or github.event.client_payload. To inspect what your run received, echo toJSON(github.event). [1][3]
Sources:
Clarify trigger intent and add conditional execution or input parameter.
The workflow triggers on both
pull_requestandworkflow_dispatch, but the environment variable setup assumes a PR context. Thegithub.event.numberis only defined for pull request events; on manual dispatch, it will be undefined, causing the Nx cache keyNX_BRANCHto be empty and potentially breaking the build cache behavior.Choose one of the following approaches:
Option 1: If manual dispatch is intentional, provide a fallback:
Option 2: If publishing previews should only happen on PRs, remove
workflow_dispatch:on: pull_request: - workflow_dispatch:📝 Committable suggestion
🤖 Prompt for AI Agents