Skip to content

Conversation

@mikael-andersson91
Copy link

What
These changes are intended to enable creation of new versions with commit hash as a postfix, without generating an associated tag.

How
Identifying pull requests is done by using the GitHub Environment variable GITHUB_EVENT_NAME to identify when the action is triggered by a pull request, read more here. This event is used in the isPr function to identify pull requests. The following functionalities has also been refactored to functions in the utils.ts file:

  • Getting identifier (getIdentifier): Uses the pull request event to make an identifier with the first seven characters of the commit hash on pull requests. On all other events it works as it did before
  • Check if prerelease branch (isPrereleaseBranch): Uses the preReleaseBranches input to identify if the currentBranch is a prerelease branch. If no preReleaseBranch was given, it returns to false.

Why
I started experimenting with these changes after creating issue #150 where I noted that the current version of this action does not generate new versions with the commit hash suffix on pull requests targeted at main branch, as described in the Filter branches section of the documentation. During this work I also noticed that some functionality could be refactored into functions for improved readability of the code. Using the environment variable for event name also seemed like a more stable way of identifying pull requests than what was previously in place.

NOTE: This is pretty much a duplicate of pull request 151 which I will be closing. Going to take the master branch of my fork in a different direction but still wanted to keep these changes as an option for this repository.

Use the GITHUB_EVENT_NAME environment variable to determine if the triggering event of the workflow was a pull request.
add test case to verify that tag does not get created on pull requests
* refactor: move prerelease branch check to function

* refactor: move prerelease identifier to function
Get commit sha as identifier on pr. Get identifier for prereleases

* fix: create tag for pull requests with shortened commit sha

* ci: update actions checkout to v3
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 this pull request may close these issues.

2 participants