git hub personal accesstoken working in local is failing in github actions

82 views Asked by At

I am trying to make a GitHub action to run a bash script and create a file in the repo, then push it to a protected branch.

i created a personal access token, from an admin account, tested it in my terminal by setting url

git remote set-url origin https://username:[email protected]/ORG/REPO.git
git push

This worked fine.

When i tried the same in github actions, its failing.

name: "name"
on: 
  push:
    branches:
      - main
      - develop
env:
  ACCESS_TOKEN: ${{ secrets.GACDTOK }}
jobs:
  proto_gen:
    name: generating stubs 
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - run: git checkout ${{ github.head_ref }}
      - uses: actions/setup-python@v4
        with:
          python-version: '3.9' 
      - run: pip install grpcio==1.35.0 protobuf==3.14.0 grpcio-tools==1.35.0
      - run: |           
          bash scripts/make_proto.sh
          git config user.name "username"
          git config user.email "email"
          git remote set-url origin https://username:[email protected]/ORG/REPO.git
          git add .
          git commit -m "commit msg"
          git push

The error i am getting is

remote: error: GH006: Protected branch update failed for refs/heads/develop.        
remote: error: Waiting on code owner review from users        
To https://github.com/ORG/REPO.git
 ! [remote rejected] develop -> develop (protected branch hook declined)
error: failed to push some refs to 'https://github.com/ORG/REPO.git'
Error: Process completed with exit code 1.

Any suggestions to fix this action?

0

There are 0 answers