question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Clarification about "working with any ref" changes

See original GitHub issue

👋 First off, thank you for this action (it’s a huge help)

I was updating my repo to the latest version v8 because I wanted to take advantage of

now work with whatever ref has been checked out, without pulling or switching branches by default.

In my workflow on a pull_request event I simply use the default option with actions/checkout@v2 here

However this fails https://github.com/prince-chrismc/label-merge-conflicts-action/runs/4892752781?check_suite_focus=true#step:8:79 with fatal: You are not currently on a branch.

My use case is very similar to the example https://github.com/EndBug/add-and-commit#automated-linting just a different event 🤔

Do you have any suggestion or ideas to help me debug this issue?

Thanks in advance ❤️

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
EndBugcommented, Jan 21, 2022

Hi, thanks for using the action!

By default actions/checkout creates a detached head state when the run is triggered by a pull_request event. If you want to commit to the head branch you would need to checkout the branch the PR is coming from in the head repo.

I would set it up like this:

- uses: actions/checkout@v2
    with:
      repository: ${{ github.event.pull_request.head.repo.full_name }}
      ref: ${{ github.event.pull_request.head.ref }}

You can find the full docs for payloads of pull_request events here.

If you’re planning on running this only on “internal” PRs then you could omit the repository input. If you’re planning to use this with PRs coming from other forks, please keep in mind that you might not have write access to that repo. You can try setting up the repo with your PAT, but honestly, I’ve never tried.

PS: I see that your workflow runs on both pull_request events and other ones: since this “custom checkout” is meant only for PRs, you could try having it run only for pull_request events, while other ones will trigger the usual checkout. If you wish to do so, you can use the step.if property, here’s the docs.

Anyway, I think this is something worthy of putting in the FAQ section of the README, since other people might want to use the action in this scenario.

I hope this solves your issue!

0reactions
EndBugcommented, Jan 23, 2022

This fix has been published in v8.0.1 (also v8 and latest). Thanks again for your contribution ❤️

Read more comments on GitHub >

github_iconTop Results From Across the Web

when a reference changes their mind, advice for new ...
Here we go... 1. When a reference changes their mind about what they'll say. ... My interview, references, and first week were all...
Read more >
Job References: What If Former Bosses Don't Work There ...
Even part-time for summer jobs I had, either the former supervisor is no longer around, the company changed names, or the company is...
Read more >
2022 Rules Changes and Points of Clarification
The rule change from last year is now permanent. During a free kick, all receiving team players must be inbounds and behind their...
Read more >
Forwarding Refs
Ref forwarding is an opt-in feature that lets some components take a ref they receive, and pass it further down (in other words,...
Read more >
GitLab CI run Job only refs AND changes
I want to run Job only for merge_requests refs AND when changes for specified files, according to official doc i create this Job...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found