Skip to content
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

PR Creation fails #301

Closed
thiagodebastos opened this issue Jun 9, 2023 · 3 comments
Closed

PR Creation fails #301

thiagodebastos opened this issue Jun 9, 2023 · 3 comments

Comments

@thiagodebastos
Copy link

Problem

I cannot use the changeset Github action since it fails to create a PR, with the following error:

/usr/bin/git push origin HEAD:changeset-release/refs/pull/35/merge --force
To https://github.com/my-account/my-repo
 + 55fdd6e...d927a56 HEAD -> changeset-release/refs/pull/35/merge (forced update)
{
  "total_count": 0,
  "incomplete_results": false,
  "items": []
}
creating pull request
Error: HttpError: Validation Failed: {"resource":"PullRequest","field":"base","code":"invalid"}
Error: Validation Failed: {"resource":"PullRequest","field":"base","code":"invalid"}
HttpError: Validation Failed: {"resource":"PullRequest","field":"base","code":"invalid"}

I can see that the commit and branch are created. So that part works fine. I am unsure how to debug the rest.

I have tried setting baseBranch to master in .changeset/config.json but this does not help.

I have also tried setting all permissions to write in case the error message was incorrect.

Any pointers in the right direction would be great as I cannot seem to find any answers out there. I will report back if I find a solution.

This error would make sense if the action is attempting to create a PR from a fork, since that permission is disabled in our repo.

Relevant parts of workflow.yml

name: Build, Test and Lint

on:
  push:
    branches: [master]
  pull_request:
    branches: [master]

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}

jobs:
  test:
    name: Test and lint packages
    runs-on: self-hosted

    permissions:
      actions: write
      pull-requests: write
      statuses: write
      contents: write
      issues: write
      security-events: write
      pages: read

    steps:
      - name: Check out code
        uses: actions/checkout@v3
        with:
          path: master

      - name: Setup pnpm
        uses: pnpm/action-setup@v2
        with:
          version: 7.15.0

      - name: Use Node.js environment
        uses: actions/setup-node@v3
        with:
          node-version: 18
          cache: "pnpm"
          always-auth: "true"

      - name: Install dependencies
        run: pnpm install

      - name: Build packages
        run: |
          pnpm build:packages

      - name: Create Release Pull Request or Publish to npm
        id: changesets
        uses: changesets/action@v1
        with:
          publish: pnpm release
          commit: "ci(changesets): version packages"
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

@thiagodebastos
Copy link
Author

Update: I think this could be happening because I am testing the action from a branch to see if release and PR creation are working as intended, and the action then tries to create a PR from this branch, when it expects to be creating a PR from master? I'm a bit confused as to how to set this up to be honest.

@thiagodebastos
Copy link
Author

I figured it out, the issue was that I didn't understand how this is all supposed to be set up and because I was testing the action in a PR to master, the error I got back about the base being invalid meant that it was looking to create a PR into master but was getting confused since it was being run from a PR into master already. Hopefully anyone who runs into this issue will find this and not be too lost in a rabbit hole!

@Szymon-dziewonski
Copy link

@thiagodebastos thank you for this issue, I had exactly same issue and error isn't most descriptive thing I've seen :D. For me it breaks my whole flow it would be nice if changesets/action would allow passing ref of branch if it cannot pull data from pull_request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants