Skip to content

support: Cannot push to protected branches using Enterprise TOKEN #1077

Open
@navachaitanyak

Description

Checklist

  • I am using the latest version of this action.
  • I have read the latest README and followed the instructions.
  • I have read the latest GitHub Actions official documentation and learned the basic spec and concepts.

Describe your question

I'm trying to push the docs directory to the gh-pages branch. Since the gh-pages branch is protected with 1 reviewer, I cannot push anything to the gh-pages branch also I want to use a token created in Enterprise GitHub
and I don't want to use github_token instead I would like to use my token which was created by the enterprise owner on enterprise GitHub

Relevant links

Public repository: Its internal enterprise repository
YAML config:
YAML workflow:

Relevant log output

Run enterprise/gha-allure-gh-pages@v3
  with:
    github_token: ***
    publish_branch: gh-pages
    publish_dir: docs
    cname: github.enterprise.com
    allow_empty_commit: false
    keep_files: false
    force_orphan: false
    enable_jekyll: false
    disable_nojekyll: false
    exclude_assets: .github
[INFO] Usage https://github.com/peaceiris/actions-gh-pages#readme
Dump inputs
  [INFO] GithubToken: true
  [INFO] PublishBranch: gh-pages
  [INFO] PublishDir: docs
  [INFO] DestinationDir: 
  [INFO] ExternalRepository: 
  [INFO] AllowEmptyCommit: false
  [INFO] KeepFiles: false
  [INFO] ForceOrphan: false
  [INFO] UserName: 
  [INFO] UserEmail: 
  [INFO] CommitMessage: 
  [INFO] FullCommitMessage: 
  [INFO] TagName: 
  [INFO] TagMessage: 
  [INFO] EnableJekyll (DisableNoJekyll): false
  [INFO] CNAME: github.enterprise.com
  [INFO] ExcludeAssets .github

Setup auth token
  [INFO] setup GITHUB_TOKEN
Prepare publishing assets
Setup Git config
  /usr/bin/git remote rm origin
  /usr/bin/git remote add origin ***github.enterprise.com/enterprise/abcd-automation.git
  /usr/bin/git add --all
  /usr/bin/git config user.name user2023
  /usr/bin/git config user.email [email protected]
Create a commit
Push the commit or tag
  /usr/bin/git push origin gh-pages
  remote: error: GH006: Protected branch update failed for refs/heads/gh-pages.        
  remote: error: At least 1 approving review is required by reviewers with write access.        
  To https://github.enterprise.com/enterprise/abcd-automation.git
   ! [remote rejected] gh-pages -> gh-pages (protected branch hook declined)
  error: failed to push some refs to 'https://github.enterprise.com/enterprise/abcd-automation.git'
  Error: Action failed with "The process '/usr/bin/git' failed with exit code 1"

Additional context.

I want to use the token at organisational level and don't want to use the token created by the runner

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions