-
Notifications
You must be signed in to change notification settings - Fork 46
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
Girhub bit branch determination is not reliable #363
Comments
i've suspected that there is an opportunity to improve the way this works for github actions, but havent had a chance to investigate far enough to understand alternatives. if you'd be willing to investigate far enough to provide detail of the alternatives available that we could use, that would really help the chances if this being improved. also, could you share some detail of your use case? i've mostly approached supporting this package from the perspective of how it is used within semantic-release. if your use case is different than that, having a better idea of your goal would be helpful |
Regarding the use case:
After the feature or set of features is tested, we merge the Release workflow is started for As the workflow trigger is At first, I assumed that in our case we can read the github file with the event data, is it is done for some of the cases, and refer to the And the only reliable way of getting the branch that I see is reading in from the If that approach is fine, I can make a PR. |
to be honest, i'm having a hard time understanding your workflow and you motivation for using it. from what i do understand about what you describe, i dont think your concern is unique to the implementation of env-ci for a github action workflow. changing the branch to a different branch than what triggered the workflow is not a currently supported workflow for any of the ci services supported by env-ci. you mention that you are using env-ci in the context of semantic-release, so i'll also highlight that the workflow you seem to be describing is not one that we would recommend using semantic-release with in the first place. semantic-release is intended to be triggered automatically when commits are pushed to a release branch. it seems like you are taking steps to make that process more manual, which is not really the intent of semantic-release. i'm wondering if your problem would simply go away if you simplified your intended workflow to a more typical workflow supported by semantic-release |
It is like that. I'm starting semantic-release on the push into the release branch. But the release branch is not the default branch of the repo and that affects the github environment variables values in the workflows. But just not to have all-in-one workflow, I split it to two workflow. First starts on push, second (that actually runs the semantic-release) starts on the first workflow successful end. And yes, it could be solved with moving everything in one workflow, but I don't see why that should be a mandatory for running semantic-release. Anyway, my point is that |
i still dont understand. being the default branch should not matter. actions workflows can be triggered by a push to any branch. i dont understand the need to switch branches with raw git after being triggered by a push to a different branch |
The workflow that runs the semantic-release is not started by the push event directrly, it is started by the Push to the release branch -> Test/typecheck Workflow run succeed -> Release workflow:
In that case, default branch setting matters, cause Release workflow is started against default branch, not the release branch. Please, have a look on the documentation: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_run and pay attention to the |
i'm familiar with triggering workflows with workflow_run, but it isnt clear to me why you would choose to use that approach for this situation over workflow_dispatch, which honors the trigger branch. i've used that approach in the past to trigger semantic-release workflows and found it to be a successful approach without any need to checkout a different branch after the workflow was triggered. (i've personally moved away from that approach in favor of using a reusable workflow rather than triggering a completely separate workflow) your chosen workflow seems unnecessarily complex when there are alternatives (worfklow_dispatch and reusable workflows) that should accomplish similar goals. if you think there is a need that is unfulfilled by the available alternatives, we would need to understand the gap very clearly before we would consider working around that complexity |
Bug
Currently, the working branch determination in the Github environment relies on the
GITHUB_REF
environment variable value.But this works correctly only if the workflow was triggered by pretty limited number of events: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows
Only the ones that update the GITHUB_REF.
For instance, in my case I start semantic-release in the workflow that is triggered by the
workflow_run
event and I explicitly checkout the repositorymain
branch in it:And in that case,
GITHUB_REF
points to the default repository branch (which isdevelop
in my case), but I'm working with themain
branch.As we anyway in the environment that should have a
git
CLI, why not just get the current branch from thegit branch
output execution, if that is possible?Environment:
The text was updated successfully, but these errors were encountered: