actions / actions/checkout

Push fails when running from pull requests from a different user

Open
#644 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
8.9k
Forks
2.8k
PR merge metrics
No merged PRs in 30d

Description

Although committing and pushing from the same account is possible with v2, whenever the workflow is running from a pull request made by a different user, the HEAD comes as detached and pushing back is not possible.

Steps to reproduce:
  1. Create new a repo with user 🐮 (ex: 🐮/date-test)
  2. Add the following workflow to the repo:
    on: [pull_request]
    
    jobs:
      add_date:
        runs-on: ubuntu-latest
        steps:
          - name: Checkout
            uses: actions/checkout@v2
            with:
              fetch-depth: 0
          - name: Add date
            run: date > date.txt
          - name: Push it 
            run: |
              git config --global user.email "actions@github.com"
              git config --global user.name "GitHub Action"
              git add date.txt
              git commit -m "Add date"
              git push
    
  3. Fork the repo from user 🐷;
  4. Make some changes, commit, and create a new PR.

Contributor guide

Open the contributing guide

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 reproducing the issue with the provided actions/checkout@v2 workflow, especially the pull request from a fork and its detached HEAD state. Trace the checkout action's pull-request handling and verify the expected behavior by confirming whether the workflow can commit and push date.txt back to the appropriate branch.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions, typescript
Domain
ci-cd, devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.