semantic-release / semantic-release/git

semantic-release(/git) not using GH_TOKEN

Open
#196 22 comments 13 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

support
Dominant language
JavaScript
Stars
339
Forks
75
Avg merge
5h 15m
Merged PRs (30d)
6

Description

We're trying to push a commit to the protected master-test branch with Github Actions after a pull request is merged (on push to master-test). I generated a personal token with appropriate access to our repo (having an admin role) but noticed that the token is probably not being used (in Personal access token settings on GitHub).

image

I went through the documentation, followed each step, but still can't make it work. I've also tried to use GIT_CREDENTIALS env variable, without success.

We're using:

  • "semantic-release": "^17.0.4"
  • "@semantic-release/git": "^9.0.0"

release.config.js

/* eslint-disable @typescript-eslint/no-var-requires */

module.exports = {
	branches: [
		'master-test'
	],
	plugins: [
		"@semantic-release/commit-analyzer",
		"@semantic-release/release-notes-generator",
		"@semantic-release/npm",
		["@semantic-release/github", {
			"assets": ["dist/**"]
		}],
		["@semantic-release/git", {
			"assets": ["dist/**/*.{js,css}", "docs", "package.json"],
			"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
		}]
	  ],
}

action setup

- name: Semantic Release
run: yarn semantic-release #runs "semantic-release --debug"
env:
  NODE_ENV: production
  GH_TOKEN: ${{ secrets.GH_TOKEN }}
  GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
  NPM_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
  NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}

output from the job

shortMessage: 'Command failed with exit code 1: git push --tags https://github.com/xxx/xxx.git HEAD:master-test',
command: 'git push --tags https://github.com/xxx/xxx.git HEAD:master-test',
exitCode: 1,
signal: undefined,
signalDescription: undefined,
stdout: '',
stderr: 'remote: error: GH006: Protected branch update failed for refs/heads/master-test. \n' +
"remote: error: You're not authorized to push to this branch. Visit https://help.github.com/articles/about-protected-branches/ for more information. \n" +
'To https://github.com/xxx/xxx.git\n' +
' ! [remote rejected] HEAD -> master-test (protected branch hook declined)\n' +
"error: failed to push some refs to 'https://github.com/xxx/xxx.git'",
failed: true,
timedOut: false,
isCanceled: false,
killed: false,

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading release.config.js and the GitHub Actions setup, then rerun yarn semantic-release --debug and compare its git push command with the protected-branch rule. Done means identifying whether the configured GH_TOKEN or GITHUB_TOKEN is accepted for master-test and documenting the required permission or configuration change.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, github-actions, javascript
Domain
ci-cd, devops, release
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.