Note I'm not young enough to know everything
See more on https://www.romainlespinasse.dev/about
GitHub Action to expose slug value of GitHub environment variables inside your GitHub workflow
License: MIT License
Note I'm not young enough to know everything
See more on https://www.romainlespinasse.dev/about
The README can be more readable using some tables, a better section split and a table of content.
Describe the bug
GITHUB_SHA_SHORT variable is not being populated in v4 for the action.
To Reproduce
Add rlespinasse/github-slug-action@v4 action
Try to access env.GITHUB_SHA_SHORT
Expected behavior
GITHUB_SHA_SHORT contains the short SHA
Additional context
I replaced rlespinasse/github-slug-action@v4 with rlespinasse/[email protected] and the variable works.
Is your feature request related to a problem? Please describe.
We're using the slug action to generate preview site URLs from git branch names. The slug is used as a subdomain (or sub-subdomain) pointing to the respective deployment.
We naively thought that the SLUG_URL slugs are good for that but realized the hard way that the hostname part of the DNS name cannot generally have underscores. It's a bit messy ( https://en.wikipedia.org/wiki/Hostname#Syntax ) but I conclude that it's at least not a safe assumption (and did in fact not work in our case).
Describe the solution you'd like
Either
SLUG_URL
(because a "URL" contains a "hostname" as a part and assuming you can use that slug anywhere in a full URL is not correct). But that would be a breaking change.SLUG_HOSTNAME
?All
Describe alternatives you've considered
Additional context
I'm sorry to come up with yet another feature request...
Describe the bug
In pull_request
events, the variable GITHUB_HEAD_REF
and GITHUB_BASE_REF
are not being populated.
For example: https://github.com/ZcashFoundation/zebra/runs/5412527394?check_suite_focus=true#step:4:28
To Reproduce
Create a branch, open a PR.
Expected behavior
GITHUB_HEAD_REF
and GITHUB_BASE_REF
should be populated with the corresponding variables
Is your feature request related to a problem? Please describe.
I have a CI pipeline in some web project that automatically updates test installations so that whenever somebody pushes some branches etc. there is a corresponding installation being setup where you can see the result. I am using this plugin to build docker images (or better put their tags) and publish them onto my testservers.
Now I have the problem that this creates many many test installations (which is expected ;) ). As PRs and branches are merged and closed the installations should go away as well. You can do that on github using
on: [delete]
in your workflow file. The problem is that this workflow is always being triggered on the default branch. This is obviously not really helpfult ;) The corresponding deleted branch/pr is available using ${{ github.event.ref }}
Describe the solution you'd like
I want to reuse the exact same logic that I am using to deploy in this case. If I could optionally specify some tag input everything would be fine. Namely I want this plugin to support something like this:
- name: Inject slug/short variables
uses: rlespinasse/[email protected]
with:
# github.ref is always the default branch for deletion...need to extract branch from delete event!
ref: ${{ github.event.ref }}
Describe alternatives you've considered
Additional context
If we follow https://github.com/actions/toolkit/blob/master/docs/action-versioning.md#versioning, this action needs to have a v4
tag that follows the latest release on the v4.x
branch and so on.
Describe the bug
In pull_request
events, the variable GITHUB_HEAD_REF
and GITHUB_BASE_REF
are not being populated.
For example: https://github.com/ZcashFoundation/zebra/runs/5412527394?check_suite_focus=true#step:4:28
To Reproduce
Create a branch, open a PR.
Expected behavior
GITHUB_HEAD_REF
and GITHUB_BASE_REF
should be populated with the corresponding variables
Following the security rules of this repository, the v3.x
branch will be removed after a 3-month period.
During this time, the security patches will be apply to it.
Hello π,
Describe the bug
We've got an error since [email protected] on GitHub Enterprise Server 3.6.2:
Here are the logs:
Run rlespinasse/github-slug-action@v4
with:
prefix: SL_SH_
slug-maxlength: 6[3](https://git.epo.org/ds/cv-pipelines/runs/52955?check_suite_focus=true#step:4:3)
Run $GITHUB_ACTION_PATH/preflight.sh
$GITHUB_ACTION_PATH/preflight.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail ***0***
env:
INPUT_SLUG_MAXLENGTH: 63
INPUT_SHORT_LENGTH:
/runner/_work/_actions/rlespinasse/github-slug-action/v[4](https://git.epo.org/ds/cv-pipelines/runs/52955?check_suite_focus=true#step:4:4)/preflight.sh: line 34: : No such file or directory
Seems that it's linked to the update to use GITHUB_OUTPUT:
https://github.com/rlespinasse/github-slug-action/pull/117/files
Why this update was needed ?
It's working well if we pin [email protected].
Thanks for your help π
I am trying to use this action with building version tags. Using this action when I create a tag e.g. v3.0.0
this variable GITHUB_REF_SLUG
will be v3-0-0
.
My suggestion is to don't replace periods or create a new environment variable that we can use for tags.
(updated to account for being able to use the prefix parameter)
Is your feature request related to a problem? Please describe.
I need a slug that, including our prefix, fits into less than 63 characters because I have a different length limit than 63.
Describe the solution you'd like
an optional with
parameter to set a different limit (or no limit if someone has that use case because technically branch names could collide).
Describe alternatives you've considered
Custom scripting, e.g. an action step that runs a script that takes the env var and provides an output. That's pretty near to building an own custom github action like this)
Additional context
Thank you very much for your work, this is a nice and useful action.
Describe the bug
GitHub releases a new environment variable: GITHUB_REF_NAME
.
Since this action also uses GITHUB_REF_NAME
name.
The GitHub version cannot be overwritten by this action, and the export is silently discarded.
The action version doesn't fill this variable the same way GitHub does.
And the current content doesn't match the content produced by this action (before the GitHub release) on pull request event.
On GitHub-side, GITHUB_REF_NAME
is GITHUB_REF
without the refs
prefix.
GITHUB_REF
= refs/pull/42/mergeGITHUB_REF_NAME
= 42/mergeGITHUB_REF_NAME
= <Name of the head branch of PR 42>To Reproduce
Use this action on a pull request-based workflow.
Expected behavior
GITHUB_REF_NAME
contains the branch behind the Pull request.
What dependency this is using that prevents it from running on other operating systems?
Due to changes into the branches management, the master
branch is not longer supported and will be removed in few months (EOL: 2020-10-25).
After a search, here is the list of projects who use master
branch for this action inside their workflows.
Describe the bug
@rlespinasse sometimes this action is getting a SHA with a length of 7 and sometimes with a length of 8, which crashes some actions.
See this examples:
Correct len(7) for GITHUB_SHA_SHORT: https://github.com/ZcashFoundation/zebra/runs/5618372155?check_suite_focus=true#step:3:977
Wrong len(8) for GITHUB_SHA_SHORT: https://github.com/ZcashFoundation/zebra/runs/5618372108?check_suite_focus=true#step:3:1017
This happens in the same action, almost duplicating the same steps
To Reproduce
Use @v4
of this action
Expected behavior
Always return the same length for the GITHUB_SHA_SHORT
v3.x
as default branchv1.x
from security fixesBased on https://github.com/rlespinasse/github-slug-action#one-of-the-environment-variables-doesnt-work-as-intended
To avoid being discarded silently, we need to print a warning upon the already existing variables set by this action.
Describe the bug
During release phase, the dist files are updated with the release
To Reproduce
Make a release π
Expected behavior
the dist files are updated with the release
Describe the bug
We're using the slug action to generate preview site URLs from git branch names. The slug is used as a subdomain (or sub-subdomain) pointing to the respective deployment. That works pretty well, mainly thanks to your quick response the last time. Thank you again for that! ππΌ
But now we ran into another issue.
We are using the SLUG_URL
to create the subdomain and slug-maxlength
to adjust the length of the slug to our needs.
We noticed that sometimes, when our branch name is too long and the slug length is being adjusted (or trimmed to the right length) that it can happen that the slug url is ending with an hyphen, which is not a valid hostname in the URL. That gives us an error when we try to create the subdomains.
If I understand the documentation correctly, the trailing -
should be removed from the slug. But I guess this is not covered when using the slug-maxlength
configuration. π€
To Reproduce
Expected behavior
The SLUG_URL should never end with a hyphen.
Screenshots
As you can see, we tried to use the SLUG_URL (our branch name) as subdomain. And in this particular case, the branch name was truncated to the configured length and ended with a hyphen.
Additional context
Thank you very much for the quick support you gave us so far! We hope we can help you with this contribution :)
This change here breaks every workflow that used the GITHUB_REF_SLUG
on services that require slugs starting with a letter.
Before it was guaranteed to have a value like refs-pull-<pr number>-merge
and now it is <pr number>-merge
.
Took us a while to find why our staging deployments suddenly stopped working. Could that be added to the release notes so others will find it more quickly?
Is your feature request related to a problem? Please describe.
When tagging a specific version of this action within a workflow, you must use the syntax x.y.z
rather than the standard vx.y.z
that all official actions make use of.
Describe the solution you'd like
Change tagging on releases to include a leading v
.
Describe alternatives you've considered
N/A
Additional context
N/A
Is your feature request related to a problem? Please describe.
The value of GITHUB_REF_SLUG
is different depending on whether a pull_request/push event is the origin.
It makes it harder to write scripts where we don't really care what's the event, we only want the branch name.
Run rlespinasse/[email protected]
##[debug]Node Action run completed with exit code 0
##[debug]GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT='8c2d7bad'
##[debug]GITHUB_REPOSITORY_OWNER_PART='UnlyEd'
##[debug]GITHUB_REPOSITORY_NAME_PART='github-action-deploy-on-vercel'
##[debug]GITHUB_REPOSITORY_SLUG='unlyed-github-action-deploy-on-vercel'
##[debug]GITHUB_REPOSITORY_SLUG_CS='UnlyEd-github-action-deploy-on-vercel'
##[debug]GITHUB_REPOSITORY_OWNER_PART_SLUG='unlyed'
##[debug]GITHUB_REPOSITORY_OWNER_PART_SLUG_CS='UnlyEd'
##[debug]GITHUB_REPOSITORY_NAME_PART_SLUG='github-action-deploy-on-vercel'
##[debug]GITHUB_REPOSITORY_NAME_PART_SLUG_CS='github-action-deploy-on-vercel'
##[debug]GITHUB_REPOSITORY_SLUG_URL='unlyed-github-action-deploy-on-vercel'
##[debug]GITHUB_REPOSITORY_SLUG_URL_CS='UnlyEd-github-action-deploy-on-vercel'
##[debug]GITHUB_REPOSITORY_OWNER_PART_SLUG_URL='unlyed'
##[debug]GITHUB_REPOSITORY_OWNER_PART_SLUG_URL_CS='UnlyEd'
##[debug]GITHUB_REPOSITORY_NAME_PART_SLUG_URL='github-action-deploy-on-vercel'
##[debug]GITHUB_REPOSITORY_NAME_PART_SLUG_URL_CS='github-action-deploy-on-vercel'
##[debug]GITHUB_REF_SLUG='18-merge'
##[debug]GITHUB_REF_SLUG_CS='18-merge'
##[debug]GITHUB_HEAD_REF_SLUG='feature-dynamic-aliases'
##[debug]GITHUB_HEAD_REF_SLUG_CS='feature-dynamic-aliases'
##[debug]GITHUB_BASE_REF_SLUG='main'
##[debug]GITHUB_BASE_REF_SLUG_CS='main'
##[debug]GITHUB_REF_SLUG_URL='18-merge'
##[debug]GITHUB_REF_SLUG_URL_CS='18-merge'
##[debug]GITHUB_HEAD_REF_SLUG_URL='feature-dynamic-aliases'
##[debug]GITHUB_HEAD_REF_SLUG_URL_CS='feature-dynamic-aliases'
##[debug]GITHUB_BASE_REF_SLUG_URL='main'
##[debug]GITHUB_BASE_REF_SLUG_URL_CS='main'
##[debug]GITHUB_SHA_SHORT='b97c3a2a'
##[debug]Finishing: Expose GitHub slug/short variables
Run rlespinasse/[email protected]
##[debug]Node Action run completed with exit code 0
##[debug]GITHUB_EVENT_REF_SLUG='feature-dynamic-aliases'
##[debug]GITHUB_EVENT_REF_SLUG_CS='feature-dynamic-aliases'
##[debug]GITHUB_EVENT_REF_SLUG_URL='feature-dynamic-aliases'
##[debug]GITHUB_EVENT_REF_SLUG_URL_CS='feature-dynamic-aliases'
##[debug]GITHUB_REPOSITORY_OWNER_PART='UnlyEd'
##[debug]GITHUB_REPOSITORY_NAME_PART='github-action-deploy-on-vercel'
##[debug]GITHUB_REPOSITORY_SLUG='unlyed-github-action-deploy-on-vercel'
##[debug]GITHUB_REPOSITORY_SLUG_CS='UnlyEd-github-action-deploy-on-vercel'
##[debug]GITHUB_REPOSITORY_OWNER_PART_SLUG='unlyed'
##[debug]GITHUB_REPOSITORY_OWNER_PART_SLUG_CS='UnlyEd'
##[debug]GITHUB_REPOSITORY_NAME_PART_SLUG='github-action-deploy-on-vercel'
##[debug]GITHUB_REPOSITORY_NAME_PART_SLUG_CS='github-action-deploy-on-vercel'
##[debug]GITHUB_REPOSITORY_SLUG_URL='unlyed-github-action-deploy-on-vercel'
##[debug]GITHUB_REPOSITORY_SLUG_URL_CS='UnlyEd-github-action-deploy-on-vercel'
##[debug]GITHUB_REPOSITORY_OWNER_PART_SLUG_URL='unlyed'
##[debug]GITHUB_REPOSITORY_OWNER_PART_SLUG_URL_CS='UnlyEd'
##[debug]GITHUB_REPOSITORY_NAME_PART_SLUG_URL='github-action-deploy-on-vercel'
##[debug]GITHUB_REPOSITORY_NAME_PART_SLUG_URL_CS='github-action-deploy-on-vercel'
##[debug]GITHUB_REF_SLUG='feature-dynamic-aliases'
##[debug]GITHUB_REF_SLUG_CS='feature-dynamic-aliases'
##[debug]GITHUB_REF_SLUG_URL='feature-dynamic-aliases'
##[debug]GITHUB_REF_SLUG_URL_CS='feature-dynamic-aliases'
##[debug]GITHUB_SHA_SHORT='8c2d7bad'
##[debug]Finishing: Expose GitHub slug/short variables
We can see in the first case we should use the GITHUB_HEAD_REF_SLUG
and in the second case it should be GITHUB_REF_SLUG
.
Describe the solution you'd like
Adding a GITHUB_BRANCH_NAME
env variable that is contains the branch name in both cases.
Describe alternatives you've considered
Writing our own custom if/else in github action, but that could be avoided.
set-env
is deprecated! GHSA-mfwh-5m23-j46w
Is your feature request related to a problem? Please describe.
I am using the GITHUB_HEAD_REF_SLUG to pass a branch name into an action. That variable is always lowercase, but my action needs the case-sensitive version of the slug.
Describe the solution you'd like
Branches are passed in with capital letters respected. Either in this variable or a new, case-sensitive one.
Is your feature request related to a problem? Please describe.
Actually, GitHub is changing the value of GITHUB_SHA
for pull request events that refers to the last merge commit on the GITHUB_REF
branch. At first, I would expect that it refers to the last commit of the branch. I wanted to use this behaviour for tagging container images build from PR events.
github-slug-action
is actually working as intended.
Describe the solution you'd like
I would like to have a way of telling github-slug-action
that I want to get the value of the last commit of my branch instead the logic used by GitHub.
Here's some track to get us started:
I did not try those solutions yet.
Describe alternatives you've considered
/
Additional context
/
WDYT?
In gitlab-ci, when github_ref is "refs/heads/feat/newFeature", CI_COMMIT_REF_SLUG will include "feat" prefix (or fix for e.g.).
It could avoid some collision between "feat/authent" and "fix/authent" for e.g.
Instead of doing this manually, we can use a GitHub Action workflow to periodically watch for newly released versions.
Hello!
I hope you are doing well!
We are a security research team. Our tool automatically detected a vulnerability in this repository. We want to disclose it responsibly. GitHub has a feature called Private vulnerability reporting, which enables security research to privately disclose a vulnerability. Unfortunately, it is not enabled for this repository.
Can you enable it, so that we can report it?
Thanks in advance!
PS: you can read about how to enable private vulnerability reporting here: https://docs.github.com/en/code-security/security-advisories/repository-security-advisories/configuring-private-vulnerability-reporting-for-a-repository
In order to improve the governance and the future of this action, I created a GitHub organization called Actions-Able which is composed of other action maintainers and co-maintainers I work with.
This issue concerns preparing the migration to this new ownership without breaking the current use of rlespinasse/github-slug-action@...
in our user workflows.
As explain in https://docs.github.com/en/actions/reference/environment-variables#naming-conventions-for-environment-variables, I think a v4.x
branch with a new naming.
What kind of naming convention we can used to fix this issue?
Post your proposal as comment
v3.x
branch failed. π¨I recommend you give this issue a high priority, so other packages depending on you can benefit from your bug fixes and new features again.
You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. Iβm sure you can fix this πͺ.
Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.
Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the v3.x
branch. You can also manually restart the failed CI job that runs semantic-release.
If you are not sure how to resolve this, here are some links that can help you:
If those donβt help, or if this issue is reporting something you think isnβt right, you can always ask the humans behind semantic-release.
semantic-release cannot push the version tag to the branch v3.x
on the remote Git repository with URL http://x-access-token:[secure]@github.com/rlespinasse/github-slug-action.git
.
This can be caused by:
Good luck with your project β¨
Your semantic-release bot π¦π
Describe the bug
Workflow including this action fails with:
Error: The input 'lenght' is mandatory with 'short-on-error' set to 'true'
Error: Process completed with exit code 1.
To Reproduce
steps:
- name: Inject GitHub Short Names
uses: rlespinasse/[email protected]
Expected behavior
Workflow does not fail.
Additional context
Note that lenght
is misspelled in the error message, which might be an indicator of where the issue stems from?
The README shows what the variables names are but not what the variable value is.
Nearly everything is in the README, maybe we can find a better way to express all documentation sections in a better structure.
Is your feature request related to a problem? Please describe.
It could be useful to get current branch, even when pipeline has been triggered by a tag event.
Describe the solution you'd like
Get a variable which provide current branch.
Describe alternatives you've considered
N/A
Additional context
N/A
Starting on v4.X branch, only a tag will have the dist
folder on a tag and not the associated branch (like now).
A branch will not be used anymore due to the fact that the action is not pre-compile inside.
As this change is a breaking one, we will use the v4.x
branch series to highlight that.
Is your feature request related to a problem? Please describe.
Need: determine the slug version of an input variable.
Depending on the workflow, github.ref
is not necessarily the desired value (especially for manual deployment workflow).
Describe the solution you'd like
A solution could be to allow to override github.ref
with ref
parameter (the default value remains what it is, so it is backward compatible).
- name: Inject slug/short variables
uses: rlespinasse/[email protected]
with:
ref: ${{ my-ref }}
Describe alternatives you've considered
Another solution could be to access the action's function via a script.
- name: Inject slug/short variables
uses: rlespinasse/[email protected]
with:
script: exportSlugRefCS("${{ my-ref }}", "MY_GITHUB_REF_SLUG_CS")
Additional context
n/a
Describe the bug
SLUG on a variable remove double - character, this behavior is not in the documentation.
On pull_request
event, the GITHUB_REF
value is refs/pull/<pr number>-merge
So,
<pr number>-merge
refs-pull-<pr number>-merge
During the migration from docker-based action (v2.x) to javascript-based action (v3.x), the bug have been introduce.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.