Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Action wouldn't work in workflow triggered by pull request #6

Open
marcinwfilewave opened this issue Nov 4, 2020 · 5 comments · May be fixed by #27
Open

Action wouldn't work in workflow triggered by pull request #6

marcinwfilewave opened this issue Nov 4, 2020 · 5 comments · May be fixed by #27

Comments

@marcinwfilewave
Copy link

Hi, we've came across this action recently and it does exactly what we need. Thank you for sharing.

That being said there is one scenario in which the action wouldn't work. Here's how you could reproduce it. Please disregard version-command that doesn't make sense, it's just for testing purposes.

.github/workflows/tag.yml

name: tag-argocd

on:
  pull_request:
    branches:
      - argocd

jobs:
  tag:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - uses: salsify/[email protected]
        with:
          create-tag: false
          version-command: |
            echo "123"

This workflow always result in failure.

Run salsify/[email protected]
  with:
    create-tag: false
    version-command: echo "123"
  
    tag-template: v{VERSION}
    tag-annotation-template: Released version {VERSION}
Previous version: 123
Error: Command failed with exit code 1: git checkout refs/pull/18/merge
error: pathspec 'refs/pull/18/merge' did not match any file(s) known to git

Would you have any advice how to fix that?

@dfreeman
Copy link
Member

Hi @marcinwfilewave, sorry for the long silence! I seem to have completely missed this issue being filed.

I'm not sure off the top of my head why this would fail for pull requests but not other workflow triggers.

Can you tell me more about why you want to run this action for PRs? I generally wouldn't want to allow anyone opening a pull request to my repo to be able to create tags every time they push a commit to their branch, but maybe you have a development flow in mind that I hadn't considered 🙂

@pinkasey
Copy link

pinkasey commented Jun 3, 2021

I just ran into this myself -
I was trying to see If I can use this cool GH Action in my repo, so my first step was to open a branch and create a new workflow, that will only run on my branch.
the lazy way to do this is:

on: pull_request

(since no other branch has this new workflow).

But that's not really something I need -
I'm now changing this to a more appropriate triger:

on:
  push:
    branches:
      # this is my test-branch:
      - eyal_ci_if_version 

@pinkasey
Copy link

pinkasey commented Jun 3, 2021

BTW,

on:
  push:
    branches:
      # this is my test-branch:
      - eyal_ci_if_version 

didn't work either, I still got the same error.

I've managed to solve it by doing this:

      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
          ref: eyal_ci_if_version

(I guess this GH action assume it will only be ran on master/main. which is reasonable. posting here to help others.)
(I also upgraded actions/checkout to v2)

@code-ape
Copy link

FYI. This issue still exists and is something I hit today. Will try and post if I track down root cause.

@code-ape
Copy link

Cause of the issue is this line below which is set to something like refs/pull/52/merge on pull requests and thus fails.

await checkout(getEnv('GITHUB_REF'));

Looks like this needs to be updated to be GITHUB_HEAD_REF if present (which is for PRs) and then fall back to GITHUB_REF.

@deeninetyone deeninetyone linked a pull request Apr 20, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants