GithubHelp home page GithubHelp logo

rlespinasse / github-slug-action Goto Github PK

View Code? Open in Web Editor NEW
247.0 247.0 35.0 1.23 MB

GitHub Action to expose slug value of GitHub environment variables inside your GitHub workflow

License: MIT License

Shell 100.00%
continuous-delivery continuous-deployment continuous-integration github-actions hacktoberfest short slug workflows

github-slug-action's Introduction

github-slug-action's People

Contributors

ameausoone avatar dependabot[bot] avatar eryajf avatar helaili avatar jbcpollak avatar madjlzz avatar nickittynack avatar php-coder avatar rlespinasse avatar semantic-release-bot avatar tryvin avatar tsmmark avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

github-slug-action's Issues

GITHUB_SHA_SHORT Not Working in V4

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.

Feature: domain name compatible slug (no underscores)

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

  • change the behavior of 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.
  • find some other means of supporting the use case. Extra exclusion characters configurable? Yet another set of variables like SLUG_HOSTNAME?

All

Describe alternatives you've considered

  • dropping this action for a custom script (not ideal, needs to be maintained too)
  • tolerating the error somehow (currently not possible, it's wrapped into other actions)

Additional context
I'm sorry to come up with yet another feature request...

Use ref as input?

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

End of life of v3

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.

Error on GitHub Enterprise Server 3.6.2 since [email protected]

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 πŸ™

Do not replace periods with dashes

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.

Feature wish: option to set a different slug length than 63

(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.

GitHub define GITHUB_REF_NAME as default environment variable

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.

  • pull-request event GITHUB_REF = refs/pull/42/merge
  • GitHub version of GITHUB_REF_NAME = 42/merge
  • Action version of GITHUB_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.

github-slug-action - master branch EOL

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.

GITHUB_SHA_SHORT returning variable length

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

dist files are not updated during release

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

Bug: `SLUG_URL` can end with a hyphen

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

  • Use a long string with hyphens in between words.
  • Use SLUG_URL with slug-maxlength to create a slug out of the string that is shorter than the original string
  • Try to find the right length of either the string or the maxlength to truncate the string that it ends with an hyphen

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.
image (1)

Additional context
Thank you very much for the quick support you gave us so far! We hope we can help you with this contribution :)

Warning for breaking changes

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?

Change Tagging To `vX.Y.Z`

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

Provide a shared env variable between "pull_request" and "push" events for the branch name

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.

Case-sensitive GITHUB_HEAD_REF_SLUG

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.

GITHUB_SHA different value for PR events

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?

Reporting a vulnerability

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

Prepare the ownership change of this action

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.

The automated release is failing 🚨

🚨 The automated release from the 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.


Cannot push to the Git repository.

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 πŸ“¦πŸš€

Error: The input 'lenght' is mandatory with 'short-on-error' set to 'true' in v4.2.0

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?

Rework the documentation

Nearly everything is in the README, maybe we can find a better way to express all documentation sections in a better structure.

Get current branch even on tag event

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

Change the way a new version is produced

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.

underscore (_) in branch name is replaced with dash (-)

Describe the bug
see issue title

To Reproduce
print the env vars and see that the branch name has dashes instead of underscores

Expected behavior
The env var should include the actual branch name, not replace any characters.

Screenshots
Screen Shot 2021-03-30 at 11 22 07 AM

Additional context
Thanks for the really useful package!

Determine variable(s) from input

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

GITHUB_REF_SLUG on pull request differs between v2.x and v3.x

On pull_request event, the GITHUB_REF value is refs/pull/<pr number>-merge
So,

  • on v2.x, the value is <pr number>-merge
  • on v3.x, the value is 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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.