Skip to content

Push issue #44

Closed
Closed

Description

@sabuto

Ok, I may be being really dumb here but

image

I get permission denied

my workflow file:

name: CI

on: [push]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
      name: Main Checkout

    - uses: actions/checkout@v2
      name: Secondary Checkout
      with:
        repository: sabuto/bot-test2
        path: bot-test2

    - name: move file to other repo
      run: \cp -Rv .github/sabubot.yml bot-test2/.github/sabubot.yml

    - name: commit to local
      run: |
        cd bot-test2
        git config --local user.email "robe_dunne@hotmail.com"
        git config --local user.name "sabuto"
        git add .
        git commit -m "Add changes"

    - name: Push changes
      uses: ad-m/github-push-action@master
      with:
        github_token: ${{ secrets.GITHUB_PSA }}
        repository: sabuto/bot-test2

I have the psa key setup in the repo that is triggering the workflow
image

which is a personal access token with all rights.

Activity

  1. robot-o commented on Feb 1, 2020

    @robot-o

    i'm having the same issue

  2. magodo commented on Feb 4, 2020

    @magodo

    For anyone suffering this issue, this might be the actions/checkout@v2 to blame. The default setting for checkout cannot work with push. To make them work together, you need to specify following parameters for checkout:

    persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
    fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
  3. sabuto commented on Feb 4, 2020

    @sabuto
    Author

    @magodo Thanks for this, I am now getting

    Started: bash /home/runner/work/_actions/ad-m/github-push-action/master/start.sh
     ! [rejected]        HEAD -> master (fetch first)
    Push to branch master
    error: failed to push some refs to '***github.com/sabuto/bot-test2.git'
    hint: Updates were rejected because the remote contains work that you do
    hint: not have locally. This is usually caused by another repository pushing
    hint: to the same ref. You may want to first integrate the remote changes
    hint: (e.g., 'git pull ...') before pushing again.

    This makes no sense as i have pulled the latest version when i run the workflow, any ideas?

  4. ad-m commented on Feb 4, 2020

    @ad-m
    Owner

    @sabuto , add force: true, but you should understand what that message mean in Git due risk of data loss.

  5. magodo commented on Feb 4, 2020

    @magodo

    Are you sure you set the fetch-depth to 0? I have this issue because of that.

  6. sabuto commented on Feb 4, 2020

    @sabuto
    Author

    Thanks for this guys! and thanks for the fast responses :) i am happy for this to be closed as it works for me but will let you decide as the other haven't commented.

  7. added a commit that references this issue on Feb 14, 2020
  8. organizejs commented on Feb 22, 2020

    @organizejs

    @magodo
    I am unable to set persist-credentials and fetch-depth as parameters under checkout.

    I'm setting it like so:

        - uses: actions/checkout@master
          persist-credentials: false
          fetch-depth: 0
    

    i get this error:

    - Your workflow file was invalid: The pipeline is not valid. .github/workflows/update.yml (Line: 17, Col: 7): Unexpected value 'persist-credentials',.github/workflows/update.yml (Line: 18, Col: 7): Unexpected value 'fetch-depth'
    
  9. ad-m commented on Feb 23, 2020

    @ad-m
    Owner

    @organizejs , missing with. Let's try:

        - uses: actions/checkout@master
          with:
             persist-credentials: false
             fetch-depth: 0
  10. StefMa commented on Feb 26, 2020

    @StefMa

    Thanks guys, that worked for me.
    But I get (together with my own commit) a second commit which is something like

    Merge abc1743 into cde9725

    Again, it seems that checkout/v2 does this.
    Another solution is to simple declare the branch you want to checkout:

        - uses: actions/checkout@master
          with:
             ref: ${{ github.event.pull_request.head.ref }}
  11. added a commit that references this issue on Mar 19, 2020
  12. added a commit that references this issue on May 26, 2020
  13. added a commit that references this issue on May 26, 2020
  14. kenorb commented on Jul 13, 2020

    @kenorb

    But I get (together with my own commit) a second commit which is something like

    Merge abc1743 into cde9725

    Again, it seems that checkout/v2 does this.

    I've got the same issue with merge commit. Related: #20.

  15. added a commit that references this issue on Oct 15, 2023
  16. added a commit that references this issue on Nov 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions