https://github.com/rlespinasse/shortify-git-revision
Shortify a git revision
https://github.com/rlespinasse/shortify-git-revision
git github-action hacktoberfest revision short
Last synced: 5 months ago
JSON representation
Shortify a git revision
- Host: GitHub
- URL: https://github.com/rlespinasse/shortify-git-revision
- Owner: rlespinasse
- License: mit
- Created: 2021-12-04T21:58:59.000Z (over 4 years ago)
- Default Branch: v1.x
- Last Pushed: 2025-11-30T22:38:30.000Z (7 months ago)
- Last Synced: 2025-12-03T08:38:59.435Z (7 months ago)
- Topics: git, github-action, hacktoberfest, revision, short
- Language: Shell
- Homepage:
- Size: 41 KB
- Stars: 0
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
README
# Shortify git revision
> [!NOTE]
> A GitHub Action that generates shortened Git revision identifiers from full-length commit hashes and exposes them as environment variables.
## Features
- Converts full Git revisions into their shortened form
- Validates revision format and handles invalid inputs
- Provides both full and shortened revisions as environment variables
- Configurable error handling for invalid revisions
## Behavior
- Creates `` and `_SHORT` environment variables for valid revisions
- Environment variables are only set when the input revision is non-empty and valid
- Handles invalid revisions based on configuration:
- Fails by default (controlled by `continue-on-error` input)
- Can be customized using `short-on-error` input to override default behavior
## Usage
- Shortify an environment variable
```yaml
- 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
```yaml
- 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
```yaml
- 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
```yaml
- 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
```yaml
- uses: actions/checkout@v3
- uses: rlespinasse/shortify-git-revision@v1
with:
name: GITHUB_SHA
```
Will **not** make available
- `GITHUB_SHA_SHORT`
## Inputs
### `name`
When providing a `revision` through the revision input, the action will use this environment variable name to store the shortened hash.
If no environment variable is specified, the action automatically creates one using the `name` input (converted to uppercase) to store the provided `revision` value.
### `revision`
The revision to shortify into an environment variable named `_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`.
> [!WARNING]
>
> - 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 |