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

Github Action incorrect behavior #96

Open
hipstersmoothie opened this issue Aug 18, 2019 · 3 comments
Open

Github Action incorrect behavior #96

hipstersmoothie opened this issue Aug 18, 2019 · 3 comments

Comments

@hipstersmoothie
Copy link

Bug

Github actions run from a PR do not have the correct env information.

run env-ci in a github action. The PR number is not present

this library uses GITHUB_EVENT_NAME https://github.com/pvdlg/env-ci/blob/master/services/github.js#L27 to check if it is a PR.

Their docs say that GITHUB_EVENT_NAME is set to pull_request when:

Triggered when a pull request is assigned, unassigned, labeled, unlabeled, opened, edited, closed, reopened, synchronize, ready_for_review, locked, unlocked or when a pull request review is requested or removed. See below to learn how this event works with forked repositories.

This variable in my action is set to push.

Environment:

@pvdlg
Copy link
Member

pvdlg commented Sep 23, 2019

How should we correctly verify if we are running on a PR?

@iamogbz
Copy link

iamogbz commented Apr 29, 2020

Not sure if there's any other way to detect without using the pull_request event. However even with that there are still some errors parsing the CI env.

{
    isCi: true,
    name: "GitHub Actions",
    service: "github",
    commit: "0e16c49d52f276979dd47d0ff11d2e2f9cc2df65",
    isPr: true,
    branch: "master",
    prBranch: "refs/pull/1/merge",
    slug: "iamogbz/github-test",
    root: "/home/runner/work/github-test/github-test",
    pr: 1,
}

Build: https://github.com/iamogbz/github-test/pull/1/checks

  1. The prBranch is wrong
GITHUB_REF=refs/pull/1/merge

https://github.com/pvdlg/env-ci/blob/73299d7f729971a2725cff8b582367f108cfb5ea/services/github.js#L27

  1. The detection uses the wrong env var
GITHUB_ACTIONS=true
GITHUB_ACTION=run1

https://github.com/pvdlg/env-ci/blob/73299d7f729971a2725cff8b582367f108cfb5ea/services/github.js#L23

  1. Does not utilize github run ids
GITHUB_RUN_ID=90747655
GITHUB_RUN_NUMBER=6
  1. Tags can be gotten from

@gr2m
Copy link
Member

gr2m commented Oct 18, 2021

We just adopted env-ci into @semantic-release. Is this problem still relevant with the latest version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants