github icon indicating copy to clipboard operation
github copied to clipboard

GitHub default url should be api.github.com

Open lholota opened this issue 5 years ago • 5 comments

Hi, I am using the semantic-release/github in a couple of my repositories it started throwing the following error lately:

[10:08:30 AM] [semantic-release] › ✖  An error occurred while running semantic-release: RequestError [HttpError]: Cookies must be enabled to use GitHub.
    at /action/node_modules/@octokit/request/dist-node/index.js:66:23
    at processTicksAndRejections (internal/process/task_queues.js:97:5) {
  status: 403,
...

Based on my investigation, this is caused by passing incorrect url to Octokit (i.e. https://github.com instead of https://api.github.com) as mentioned in this issue in Octokit.

As it seems, the default url is github.com. Mitigation is possible using the GH_URL or GITHUB_URL environment variables. But given that this is the default value which might be used by many people, I think this should be updated.

Logs can be found in one my repo's CI/CD run

lholota avatar May 15 '20 10:05 lholota

This was fixed by https://github.com/semantic-release/github/pull/269, make sure to update your lock file so you get the latest version.

gr2m avatar May 17 '20 15:05 gr2m

I have the same error and already updated to 7.0.6. I also cannot get it to work with the GITHUB_API_URL environment variable. No matter what I do, the release fails.

Also one other strange thing I noticed: when the release fails it does not open an issue on Github, but creates a tag and publishes a package. This makes the release half broken and every time the action fails I need to bump the version. Is this intended or am I doing something wrong?

https://github.com/Silthus/sLib/runs/699757716?check_suite_focus=true#step:8:73

[1:36:29 PM] [semantic-release] › ✖  An error occurred while running semantic-release: RequestError [HttpError]: Cookies must be enabled to use GitHub.
    at /home/runner/work/sLib/sLib/node_modules/@octokit/request/dist-node/index.js:66:23
    at processTicksAndRejections (internal/process/task_queues.js:97:5) {
  status: 403,

package.json

{
  "devDependencies": {
    "@semantic-release/changelog": "5.0.1",
    "@semantic-release/commit-analyzer": "8.0.1",
    "@semantic-release/git": "9.0.0",
    "@semantic-release/github": "7.0.6",
    "@semantic-release/release-notes-generator": "9.0.1",
    "commitlint": "8.3.5",
    "conventional-changelog-conventionalcommits": "4.3.0",
    "gradle-semantic-release-plugin": "1.4.1",
    "husky": "4.2.5",
    "lint-staged": "10.2.6",
    "prettier": "2.0.5",
    "semantic-release": "17.0.7"
  },
  "scripts": {
    "semantic-release": "npx semantic-release"
  },
  "husky": {
    "hooks": {
      "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
    }
  },
  "lint-staged": {
    "*.{md,json}": [
      "prettier --write",
      "git add"
    ],
    "*.{gradle,java}": [
      "git add"
    ]
  },
  "release": {
    "plugins": [
      "@semantic-release/commit-analyzer",
      "@semantic-release/release-notes-generator",
      "@semantic-release/changelog",
      "gradle-semantic-release-plugin",
      [
        "@semantic-release/github",
        {
          "assets": [
            {
              "path": "**/build/libs/*.jar"
            }
          ]
        }
      ],
      [
        "@semantic-release/git",
        {
          "assets": [
            "gradle.properties",
            "CHANGELOG.md"
          ]
        }
      ]
    ]
  },
  "engines": {
    "node": ">=12.14"
  }
}

Silthus avatar May 22 '20 13:05 Silthus

I think it only creates an issue if the verify step failed, which it didn't in this case.

I'm not sure why it still gets the config wrong, but it definitely sends the request to https://github.com instead of https://api.github.com: https://github.com/Silthus/sLib/runs/699757716?check_suite_focus=true#step:8:99

gr2m avatar May 22 '20 18:05 gr2m

Any idea what I can do about the failing releases?

The strange think is that I have another repository using the exact same build process and that works: https://github.com/Silthus/spigot-plugin-template

Silthus avatar May 23 '20 07:05 Silthus

I don't know what the problem could be and I can't investigate further I'm afraid. My first guess woudl be that somehow you still have an outdated semantic-release version running somewhere ... In the build that failed, you are using a semantic-release action: https://github.com/homecentr/docker-base/actions/runs/105566028/workflow#L16-L19, maybe try to use run: npx semantic-release instead

gr2m avatar May 24 '20 17:05 gr2m