Checkout: Push to protected branch

Created on 6 Sep 2020  路  2Comments  路  Source: actions/checkout

I have managed to get pushing to a branch working fine but I'd like to push to master which is a protected branch. However if I am on my local machine I can push to master, I assume as I am the owner of the org and repo? Is there any way to use the token or identify myself so the action can make a commit using my name and email and push to the protected branch?

Most helpful comment

I have the exact same issue on typescript-eslint, you can see the configuration here:

https://github.com/typescript-eslint/typescript-eslint/commit/19516dee04c37e33ca176d1e5715457f6bdf37d7

And the resulting failure from running the action here:

https://github.com/typescript-eslint/typescript-eslint/runs/1084722742?check_suite_focus=true


This issue does seem to be specific to github actions. I have an Azure DevOps release pipeline using the exact same lerna configuration using the _exact same PAT_.

What is github actions doing differently?

Also FYI, A number of folks seem to be running into this and have reported it on the lerna repo here: https://github.com/lerna/lerna/issues/1957

All 2 comments

I have the exact same issue on typescript-eslint, you can see the configuration here:

https://github.com/typescript-eslint/typescript-eslint/commit/19516dee04c37e33ca176d1e5715457f6bdf37d7

And the resulting failure from running the action here:

https://github.com/typescript-eslint/typescript-eslint/runs/1084722742?check_suite_focus=true


This issue does seem to be specific to github actions. I have an Azure DevOps release pipeline using the exact same lerna configuration using the _exact same PAT_.

What is github actions doing differently?

Also FYI, A number of folks seem to be running into this and have reported it on the lerna repo here: https://github.com/lerna/lerna/issues/1957

i was having the same issue and then i made a personal access token to use instead of the GITHUB_TOKEN

example

name: PUBLISH NPM PACKAGE
on:
  push:
    branches: [ release ]
jobs:
  run-checks:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [15.x]
    env: 
      KIIPO_BOT_NPM_AUTOMATION_TOKEN: ${{ secrets.KIIPO_BOT_NPM_AUTOMATION_TOKEN }}
    steps:
    - uses: actions/checkout@v2
      with:
        token: ${{ secrets.KIIPO_BOT_GITHUB_REPOSITORY_ADMIN_TOKEN }}
    - name: Use node version ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}
    - run: git config user.name "kiipobot"
    - run: git config user.email "[email protected]"
    - run: npm ci 
    - run: npm run lint
    - run: npm run release:ci 

this allows me to push without problem, however it triggers a new push event which retriggers my action workflow. In effect a loop that contiues to update my package version number and publish it to npm.

so even though i can now push with a personal access token, its not a solution.

when i then disable my branch protections and use the original GITHUB_TOKEN i can push and it does not re trigger the push event

does anyone know how to use a personal access token to commit and push without re-triggering the push event ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chorrell picture chorrell  路  4Comments

rster2002 picture rster2002  路  7Comments

gordinmitya picture gordinmitya  路  7Comments

rectalogic picture rectalogic  路  5Comments

nelsonjchen picture nelsonjchen  路  5Comments