changesets / action

685 stars 245 forks source link

HttpError: Not Found #346

Open zhaohuanyuu opened 9 months ago

zhaohuanyuu commented 9 months ago

error log

Run changesets/action@v[1](https://github.com/zhaohuanyuu/wid-cli/actions/runs/7356642052/job/20027089392#step:7:1)
setting git user
/usr/bin/git config user.name "github-actions[bot]"
/usr/bin/git config user.email "github-actions[bot]@users.noreply.github.com"
setting GitHub credentials
/usr/bin/git checkout changeset-release/main
error: pathspec 'changeset-release/main' did not match any file(s) known to git
/usr/bin/git checkout -b changeset-release/main
Switched to a new branch 'changeset-release/main'
/usr/bin/git reset --hard 97bf9fbe7230df12e3d9552ccfc5e80318cfe8ba
HEAD is now at 97bf9fb test: changeset workflow modified
/opt/hostedtoolcache/node/20.[10](https://github.com/zhaohuanyuu/wid-cli/actions/runs/7356642052/job/20027089392#step:7:11).0/x64/bin/node /home/runner/work/wid-cli/wid-cli/node_modules/.pnpm/@changesets+cli@2.27.1/node_modules/@changesets/cli/bin.js version
šŸ¦‹  All files have been updated. Review them and commit at your leisure
/usr/bin/git status --porcelain
 D .changeset/gold-pots-juggle.md
 D .changeset/rich-rocks-smash.md
 D .changeset/swift-numbers-lay.md
 M package.json
?? CHANGELOG.md
/usr/bin/git add .
/usr/bin/git commit -m Version Packages
[changeset-release/main bee8d42] Version Packages
 5 files changed, 10 insertions(+), [16](https://github.com/zhaohuanyuu/wid-cli/actions/runs/7356642052/job/20027089392#step:7:17) deletions(-)
 delete mode 100644 .changeset/gold-pots-juggle.md
 delete mode 100644 .changeset/rich-rocks-smash.md
 delete mode 100644 .changeset/swift-numbers-lay.md
 create mode 100644 CHANGELOG.md
/usr/bin/git push origin HEAD:changeset-release/main --force
remote: 
remote: Create a pull request for 'changeset-release/main' on GitHub by visiting:        
remote:      https://github.com/zhaohuanyuu/wid-cli/pull/new/changeset-release/main        
remote: 
To https://github.com/zhaohuanyuu/wid-cli
 * [new branch]      HEAD -> changeset-release/main
{
  "total_count": 0,
  "incomplete_results": false,
  "items": []
}
creating pull request
Error: HttpError: Not Found
Error: Not Found

realease yml

name: Release
on:
  push:
    branches: [main]

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

jobs:
  publish-npm:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: pnpm/action-setup@v2
        with:
          version: 8
      - uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: "pnpm"
      - run: pnpm install
      - run: pnpm build
      - name: Create Release Pull Request or Publish
        id: changesets
        uses: changesets/action@v1
        with:
          publish: pnpm run publish
        env:
          GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
          NPM_TOKEN: ${{ secrets.NPM_PAKCAGE_RELEASE }}
charlie-bud commented 9 months ago

+1 - We're also experiencing the same issue with this action.

swapnil-srivastava commented 8 months ago

+1 experiencing the same issue while publishing using changeset with github actions

MartinPlayon commented 8 months ago

+1 Here. I'm not really sure if there is some setting. but it happens with GitHub actions

Run changesets/action@v1
setting git user
/usr/bin/git config user.name "github-actions[bot]"
/usr/bin/git config user.email "github-actions[bot]@users.noreply.github.com"
setting GitHub credentials
/usr/bin/git checkout changeset-release/refs/pull/22/merge
error: pathspec 'changeset-release/refs/pull/22/merge' did not match any file(s) known to git
/usr/bin/git checkout -b changeset-release/refs/pull/22/merge
Switched to a new branch 'changeset-release/refs/pull/22/merge'
/usr/bin/git reset --hard d6fbe8c8dc5[7](https://github.com/playon/components-stadium/actions/runs/7906010863/job/21579893443#step:5:8)19deb1ebd60e173ef1057[8](https://github.com/playon/components-stadium/actions/runs/7906010863/job/21579893443#step:5:9)a747cd
HEAD is now at d6fbe8c Merge 34437afcbe4e0356e24[9](https://github.com/playon/components-stadium/actions/runs/7906010863/job/21579893443#step:5:10)2aa6b74ff61518232a82 into 71c248d6dabd1521a6bcdc308aee3a7ab2612db0
/opt/hostedtoolcache/node/20.11.0/x64/bin/node /home/runner/work/components-stadium/components-stadium/node_modules/@changesets/cli/bin.js version
šŸ¦‹  All files have been updated. Review them and commit at your leisure
/usr/bin/git status --porcelain
 D .changeset/blue-impalas-swim.md
 D .changeset/cyan-weeks-work.md
 D .changeset/fluffy-yaks-jam.md
 D .changeset/good-pens-swim.md
 D .changeset/silly-cougars-bow.md
 M CHANGELOG.md
 M package.json
/usr/bin/git add .
/usr/bin/git commit -m Version Packages
[changeset-release/refs/pull/22/merge 9001c76] Version Packages
 7 files changed, 17 insertions(+), 26 deletions(-)
 delete mode [10](https://github.com/playon/components-stadium/actions/runs/7906010863/job/21579893443#step:5:11)0644 .changeset/blue-impalas-swim.md
 delete mode 100644 .changeset/cyan-weeks-work.md
 delete mode 100644 .changeset/fluffy-yaks-jam.md
 delete mode 100644 .changeset/good-pens-swim.md
 delete mode 100644 .changeset/silly-cougars-bow.md
/usr/bin/git push origin HEAD:changeset-release/refs/pull/[22](https://github.com/playon/components-stadium/actions/runs/7906010863/job/21579893443#step:5:23)/merge --force
remote: 
remote: Create a pull request for 'changeset-release/refs/pull/22/merge' on GitHub by visiting:        
remote:      https://github.com/playon/components-stadium/pull/new/changeset-release/refs/pull/22/merge        
remote: 
To https://github.com/playon/components-stadium
 * [new branch]      HEAD -> changeset-release/refs/pull/22/merge
{
  "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"}
BartoszKut commented 6 months ago

+1 Almost the same output as @MartinPlayon.

MartinPlayon commented 6 months ago

Adding more information. I would think it's something with permissions with GitHub.

BartoszKut commented 6 months ago

I've added permissions as follows, and that fixes my issue.

permissions:
  id-token: write
  contents: write
  checks: write
  issues: write
  packages: write
  pull-request: write

In your case, not all of these must be required.

MartinPlayon commented 6 months ago

@BartoszKut, thank you for the info, but it doesn't look like the issue is there.

I think the problem lies in configuring the baseBranch value. On an issue in the changeset repo when a developer's main branch doesn't have the latest, there can be an issue in resolving the correct version issue. The solution was to configure "baseBranch": "origin/main",

However, when creating the PR, it uses this value, and origin/ doesn't exist in GitHub actions. There should be a way to override the value to another branch if the default behavior is not the expected one.

MartinPlayon commented 5 months ago

I did find the issue. If you have set in your config.json the "baseBranch": "origin/main" to point to the origin, then that is not a valid branch in the actions. However, it is not really well documented. I found in the code that there is a branch value that can be passed to specify on which branch the action is running, and that will fix the HTTP error issue.

- name: Publish Package
        id: changesets
        uses: changesets/action@v1
        with:
          branch: main
          publish: yarn release
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steven-fe commented 2 months ago

You need check "public_repo" .

image