Coder Social home page Coder Social logo

shortify-git-revision's Introduction

Shortify git revision

Github Action to shortify a git revision

Produce short revision environment variable based on the input one.

If a revision is a bad revision, this action will produce an error message and fail depending on continue-on-error input (This behavior can be override with short-on-error input). <NAME>, and <NAME>_SHORT environment variable will only be available if the revision is not empty and valid.

Usage

  • Shortify an environment variable

    - uses: actions/checkout@v3
    - uses: rlespinasse/shortify-git-revision@v1
      with:
        name: GITHUB_SHA

    Will make available

    • GITHUB_SHA_SHORT
  • Shortify an environment variable with prefix

    - uses: actions/checkout@v3
    - uses: rlespinasse/shortify-git-revision@v1
      with:
        name: GITHUB_SHA
        prefix: CI_

    Will make available

    • CI_GITHUB_SHA
    • CI_GITHUB_SHA_SHORT
  • Shortify any revision

    - uses: actions/checkout@v3
    - uses: rlespinasse/shortify-git-revision@v1
      with:
        name: SOME_REVISION
        revision: 88428f56bd9d2751c47106bedfd148162dfa50b8

    Will make available

    • SOME_REVISION
    • SOME_REVISION_SHORT
  • Shortify a revision with a specific length

    - uses: actions/checkout@v3
    - uses: rlespinasse/shortify-git-revision@v1
      with:
        name: SIZED_REVISION
        revision: 88428f56bd9d2751c47106bedfd148162dfa50b8
        length: 10

    Will make available

    • SIZED_REVISION
    • SIZED_REVISION_SHORT (with value 88428f56bd)
  • Shortify without publishing the environment variables

    - uses: actions/checkout@v3
    - uses: rlespinasse/shortify-git-revision@v1
      with:
        name: GITHUB_SHA

    Will not make available

    • GITHUB_SHA_SHORT

Inputs

name

If used with revision input, it's the name of the environment variable containing the revision to shortify. Otherwise, the name input will be used (in upper case) to define a environment variable containing the revision input value.

revision

The revision to shortify into an environment variable named <NAME>_SHORT.

This input is Optional.

continue-on-error

If the input is set to true, this action will not fail on a bad revision

The default value is false.

short-on-error

If the input is set to true, this action will short a bad revision

The default value is false.

If this input is set to true, the input continue-on-error input will be ignored. If this input is set to true, the input length input is mandatory.

prefix

The value will be prepend to each generated variable.

This input is Optional.

length

the short sha produce will have the length defined by the input.

This input is Optional.

Outputs

Output Description
revision The revision to be shortify
short Revision Short

shortify-git-revision's People

Contributors

dependabot[bot] avatar rlespinasse avatar

Watchers

 avatar  avatar  avatar

shortify-git-revision's Issues

Access values using action outputs

In addition to the environment variables, we want to access the values as action outputs.

- id: short-github-sha
  uses: rlespinasse/[email protected]
  with:
     name: GITHUB_SHA
- run: |
          echo "${{ steps.short-github-sha.outputs.value }} is the same as ${{ env.GITHUB_SHA }}"
          echo "${{ steps.short-github-sha.outputs.short }} is the same as ${{ env.GITHUB_SHA_SHORT }}"

The publish-env input (as boolean) enable us to disable the publication as an environment variable
And the prefix input is not used in this context.

Export variables with prefix

Current situation

- uses: rlespinasse/[email protected]
  with:
    name: GITHUB_SHA

Will make available

  • GITHUB_SHA_SHORT

Proposition

In addition to the current mode, we add a new input prefix

- uses: rlespinasse/[email protected]
 with:
   name: GITHUB_SHA
   prefix: CI_

Will make available

  • CI_GITHUB_SHA_SHORT

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/shortify-git-revision@... in our user workflows.

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.