mirror of
https://github.com/rlespinasse/shortify-git-revision.git
synced 2026-06-13 17:30:50 +00:00
Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4370ee356b | ||
|
|
d6e06c91c1 | ||
|
|
6a2b4fbd8b | ||
|
|
5ca673ee12 | ||
|
|
667baa2431 | ||
|
|
1f6c2ce958 | ||
|
|
63a2ec32da | ||
|
|
27d97cb8a5 | ||
|
|
eecf0dcdbb | ||
|
|
b83eb1fa3b | ||
|
|
360678aba9 | ||
|
|
fc0cbcc40d | ||
|
|
c90ba7007e | ||
|
|
3b1b863e54 | ||
|
|
4c6b226848 | ||
|
|
8198b7ea44 | ||
|
|
4936ef9a58 | ||
|
|
ef0d40cdf6 | ||
|
|
512ffd9023 |
1
.github/CODEOWNERS
vendored
Normal file
1
.github/CODEOWNERS
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
* @rlespinasse
|
||||||
23
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
23
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Create a report to help us improve
|
||||||
|
title: ''
|
||||||
|
labels: bug
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Describe the bug**
|
||||||
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
|
**To Reproduce**
|
||||||
|
Steps to reproduce the behavior
|
||||||
|
|
||||||
|
**Expected behavior**
|
||||||
|
A clear and concise description of what you expected to happen.
|
||||||
|
|
||||||
|
**Screenshots**
|
||||||
|
If applicable, add screenshots to help explain your problem.
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context about the problem here.
|
||||||
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
name: Feature request
|
||||||
|
about: Suggest an idea for this project
|
||||||
|
title: ''
|
||||||
|
labels: enhancement
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Is your feature request related to a problem? Please describe.**
|
||||||
|
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||||
|
|
||||||
|
**Describe the solution you'd like**
|
||||||
|
A clear and concise description of what you want to happen.
|
||||||
|
|
||||||
|
**Describe alternatives you've considered**
|
||||||
|
A clear and concise description of any alternative solutions or features you've considered.
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context or screenshots about the feature request here.
|
||||||
11
.github/dependabot.yml
vendored
Normal file
11
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: 'github-actions'
|
||||||
|
directory: '/'
|
||||||
|
schedule:
|
||||||
|
interval: 'weekly'
|
||||||
|
groups:
|
||||||
|
dependencies:
|
||||||
|
patterns:
|
||||||
|
- '*'
|
||||||
|
labels: []
|
||||||
30
.github/workflows/linter.yml
vendored
Normal file
30
.github/workflows/linter.yml
vendored
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
---
|
||||||
|
name: Lint Code Base
|
||||||
|
|
||||||
|
on: pull_request
|
||||||
|
|
||||||
|
permissions: read-all
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Lint Code Base
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: read
|
||||||
|
statuses: write
|
||||||
|
steps:
|
||||||
|
- name: Checkout Code
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
# Full git history is needed to get a proper
|
||||||
|
# list of changed files within `super-linter`
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Lint Code Base
|
||||||
|
uses: super-linter/super-linter@v8
|
||||||
|
env:
|
||||||
|
VALIDATE_ALL_CODEBASE: false
|
||||||
|
VALIDATE_GITHUB_ACTIONS_ZIZMOR: false
|
||||||
|
VALIDATE_YAML_PRETTIER: false
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
151
.github/workflows/shortify-git-revision.yaml
vendored
151
.github/workflows/shortify-git-revision.yaml
vendored
@@ -1,21 +1,25 @@
|
|||||||
name: Shortify git revision testing
|
---
|
||||||
on: [push]
|
name: Shortify Git Revision
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- v1.x
|
||||||
|
pull_request:
|
||||||
|
permissions: read-all
|
||||||
jobs:
|
jobs:
|
||||||
shortify-git-revision-on-os:
|
os-testing:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, ubuntu-latest, windows-latest]
|
os: [macos-latest, ubuntu-latest, windows-latest]
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
concurrency:
|
|
||||||
group: shortify-git-revision-on-os-${{ github.ref }}
|
|
||||||
cancel-in-progress: true
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
# Test 1
|
# Test 1
|
||||||
- name: Shortify an existing git revision
|
- name: Shortify an existing git revision
|
||||||
|
id: shortify-an-existing-git-revision
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
name: ROOT_COMMIT
|
name: ROOT_COMMIT
|
||||||
@@ -24,6 +28,8 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
[[ "${{ env.ROOT_COMMIT }}" == "88428f56bd9d2751c47106bedfd148162dfa50b8" ]]
|
[[ "${{ env.ROOT_COMMIT }}" == "88428f56bd9d2751c47106bedfd148162dfa50b8" ]]
|
||||||
[[ "${{ env.ROOT_COMMIT_SHORT }}" == "88428f5" ]]
|
[[ "${{ env.ROOT_COMMIT_SHORT }}" == "88428f5" ]]
|
||||||
|
[[ "${{ env.ROOT_COMMIT }}" == "${{ steps.shortify-an-existing-git-revision.outputs.revision }}" ]]
|
||||||
|
[[ "${{ env.ROOT_COMMIT_SHORT }}" == "${{ steps.shortify-an-existing-git-revision.outputs.short }}" ]]
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
# Test 2
|
# Test 2
|
||||||
@@ -93,15 +99,128 @@ jobs:
|
|||||||
[[ -z "${{ env.WRONG_AND_MISSING_REVISION_SHORT }}" ]]
|
[[ -z "${{ env.WRONG_AND_MISSING_REVISION_SHORT }}" ]]
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
shortify-git-revision-release:
|
# Test 7
|
||||||
runs-on: ubuntu-latest
|
- name: Shortify a git revision with specific length
|
||||||
concurrency:
|
uses: ./
|
||||||
group: shortify-git-revision-release-${{ github.ref }}
|
with:
|
||||||
needs: shortify-git-revision-on-os
|
name: SIZED_REVISION
|
||||||
|
revision: 88428f56bd9d2751c47106bedfd148162dfa50b8
|
||||||
|
length: 10
|
||||||
|
- name: Validate // Shortify a git revision with specific length
|
||||||
|
run: |
|
||||||
|
[[ "${{ env.SIZED_REVISION }}" == "88428f56bd9d2751c47106bedfd148162dfa50b8" ]]
|
||||||
|
[[ "${{ env.SIZED_REVISION_SHORT }}" == "88428f56bd" ]]
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
# Test 8
|
||||||
|
- id: test-shortify-git-revision-with-wrong-length
|
||||||
|
name: Shortify a git revision with wrong length
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
name: WRONGFULLY_SIZED_REVISION
|
||||||
|
revision: 88428f56bd9d2751c47106bedfd148162dfa50b8
|
||||||
|
length: "not_a_number"
|
||||||
|
continue-on-error: true
|
||||||
|
- name: Validate // Shortify a git revision with wrong length
|
||||||
|
run: |
|
||||||
|
[[ -z "${{ env.WRONGFULLY_SIZED_REVISION }}" ]]
|
||||||
|
[[ -z "${{ env.WRONGFULLY_SIZED_REVISION_SHORT }}" ]]
|
||||||
|
[[ "${{ steps.test-shortify-git-revision-with-wrong-length.outcome }}" == "failure" ]]
|
||||||
|
[[ "${{ steps.test-shortify-git-revision-with-wrong-length.conclusion }}" == "success" ]]
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
# Test 9
|
||||||
|
- name: Shortify a git revision with wrong length without failing
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
name: WRONGFULLY_SIZED_REVISION
|
||||||
|
revision: 88428f56bd9d2751c47106bedfd148162dfa50b8
|
||||||
|
length: "not_a_number"
|
||||||
|
continue-on-error: true
|
||||||
|
- name: Validate // Shortify a git revision with wrong length without failing
|
||||||
|
run: |
|
||||||
|
[[ "${{ env.WRONGFULLY_SIZED_REVISION }}" == "88428f56bd9d2751c47106bedfd148162dfa50b8" ]]
|
||||||
|
[[ "${{ env.WRONGFULLY_SIZED_REVISION_SHORT }}" == "88428f5" ]]
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
# Test 10
|
||||||
|
- name: Shortify an existing git revision without env publication
|
||||||
|
id: shortify-an-existing-git-revision-without-env-publication
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
name: SHORT_WITHOUT_ENV_PUBLICATION
|
||||||
|
revision: 88428f56bd9d2751c47106bedfd148162dfa50b8
|
||||||
|
publish-env: false
|
||||||
|
- name: Validate // Shortify an existing git revision without env publication
|
||||||
|
run: |
|
||||||
|
[[ -z "${{ env.SHORT_WITHOUT_ENV_PUBLICATION }}" ]]
|
||||||
|
[[ -z "${{ env.SHORT_WITHOUT_ENV_PUBLICATION }}" ]]
|
||||||
|
[[ "${{ steps.shortify-an-existing-git-revision-without-env-publication.outputs.revision }}" == "88428f56bd9d2751c47106bedfd148162dfa50b8" ]]
|
||||||
|
[[ "${{ steps.shortify-an-existing-git-revision-without-env-publication.outputs.short }}" == "88428f5" ]]
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
error-os-testing:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [macos-latest, ubuntu-latest, windows-latest]
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
path: this-action
|
||||||
|
ref: ${{ github.ref }}
|
||||||
|
|
||||||
# Release
|
# Test 1
|
||||||
- name: Release this GitHub Action
|
- name: Continue on error
|
||||||
uses: rlespinasse/release-that@v1.x
|
uses: ./this-action
|
||||||
|
with:
|
||||||
|
name: ROOT_COMMIT
|
||||||
|
revision: 88428f56bd9d2751c47106bedfd148162dfa50b8
|
||||||
|
continue-on-error: true
|
||||||
|
- name: Validate // Continue on error
|
||||||
|
run: |
|
||||||
|
[[ "${{ env.ROOT_COMMIT }}" == "" ]]
|
||||||
|
[[ "${{ env.ROOT_COMMIT_SHORT }}" == "" ]]
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
# Test 2
|
||||||
|
- name: Short on error
|
||||||
|
id: short-on-error
|
||||||
|
uses: ./this-action
|
||||||
|
with:
|
||||||
|
name: ROOT_COMMIT
|
||||||
|
revision: 88428f56bd9d2751c47106bedfd148162dfa50b8
|
||||||
|
short-on-error: true
|
||||||
|
length: 7
|
||||||
|
- name: Validate // Short on error
|
||||||
|
run: |
|
||||||
|
[[ "${{ env.ROOT_COMMIT }}" == "88428f56bd9d2751c47106bedfd148162dfa50b8" ]]
|
||||||
|
[[ "${{ env.ROOT_COMMIT_SHORT }}" == "88428f5" ]]
|
||||||
|
[[ "${{ env.ROOT_COMMIT }}" == "${{ steps.short-on-error.outputs.revision }}" ]]
|
||||||
|
[[ "${{ env.ROOT_COMMIT_SHORT }}" == "${{ steps.short-on-error.outputs.short }}" ]]
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs:
|
||||||
|
- os-testing
|
||||||
|
- error-os-testing
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
issues: write
|
||||||
|
id-token: write
|
||||||
|
packages: write
|
||||||
|
concurrency:
|
||||||
|
group: release-${{ github.ref }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
|
||||||
|
- name: Release That
|
||||||
|
uses: rlespinasse/release-that@v1
|
||||||
|
with:
|
||||||
|
github-token: ${{ secrets.GH_TOKEN }}
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ We as members, contributors, and leaders pledge to make participation in our
|
|||||||
community a harassment-free experience for everyone, regardless of age, body
|
community a harassment-free experience for everyone, regardless of age, body
|
||||||
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||||
identity and expression, level of experience, education, socio-economic status,
|
identity and expression, level of experience, education, socio-economic status,
|
||||||
nationality, personal appearance, race, religion, or sexual identity
|
nationality, personal appearance, race, caste, color, religion, or sexual
|
||||||
and orientation.
|
identity and orientation.
|
||||||
|
|
||||||
We pledge to act and interact in ways that contribute to an open, welcoming,
|
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||||
diverse, inclusive, and healthy community.
|
diverse, inclusive, and healthy community.
|
||||||
@@ -22,17 +22,17 @@ community include:
|
|||||||
* Giving and gracefully accepting constructive feedback
|
* Giving and gracefully accepting constructive feedback
|
||||||
* Accepting responsibility and apologizing to those affected by our mistakes,
|
* Accepting responsibility and apologizing to those affected by our mistakes,
|
||||||
and learning from the experience
|
and learning from the experience
|
||||||
* Focusing on what is best not just for us as individuals, but for the
|
* Focusing on what is best not just for us as individuals, but for the overall
|
||||||
overall community
|
community
|
||||||
|
|
||||||
Examples of unacceptable behavior include:
|
Examples of unacceptable behavior include:
|
||||||
|
|
||||||
* The use of sexualized language or imagery, and sexual attention or
|
* The use of sexualized language or imagery, and sexual attention or advances of
|
||||||
advances of any kind
|
any kind
|
||||||
* Trolling, insulting or derogatory comments, and personal or political attacks
|
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||||
* Public or private harassment
|
* Public or private harassment
|
||||||
* Publishing others' private information, such as a physical or email
|
* Publishing others' private information, such as a physical or email address,
|
||||||
address, without their explicit permission
|
without their explicit permission
|
||||||
* Other conduct which could reasonably be considered inappropriate in a
|
* Other conduct which could reasonably be considered inappropriate in a
|
||||||
professional setting
|
professional setting
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ decisions when appropriate.
|
|||||||
|
|
||||||
This Code of Conduct applies within all community spaces, and also applies when
|
This Code of Conduct applies within all community spaces, and also applies when
|
||||||
an individual is officially representing the community in public spaces.
|
an individual is officially representing the community in public spaces.
|
||||||
Examples of representing our community include using an official e-mail address,
|
Examples of representing our community include using an official email address,
|
||||||
posting via an official social media account, or acting as an appointed
|
posting via an official social media account, or acting as an appointed
|
||||||
representative at an online or offline event.
|
representative at an online or offline event.
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ representative at an online or offline event.
|
|||||||
|
|
||||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||||
reported to the community leaders responsible for enforcement at
|
reported to the community leaders responsible for enforcement at
|
||||||
romain.lespinasse@gmail.com.
|
<romain.lespinasse@gmail.com>.
|
||||||
All complaints will be reviewed and investigated promptly and fairly.
|
All complaints will be reviewed and investigated promptly and fairly.
|
||||||
|
|
||||||
All community leaders are obligated to respect the privacy and security of the
|
All community leaders are obligated to respect the privacy and security of the
|
||||||
@@ -82,15 +82,15 @@ behavior was inappropriate. A public apology may be requested.
|
|||||||
|
|
||||||
### 2. Warning
|
### 2. Warning
|
||||||
|
|
||||||
**Community Impact**: A violation through a single incident or series
|
**Community Impact**: A violation through a single incident or series of
|
||||||
of actions.
|
actions.
|
||||||
|
|
||||||
**Consequence**: A warning with consequences for continued behavior. No
|
**Consequence**: A warning with consequences for continued behavior. No
|
||||||
interaction with the people involved, including unsolicited interaction with
|
interaction with the people involved, including unsolicited interaction with
|
||||||
those enforcing the Code of Conduct, for a specified period of time. This
|
those enforcing the Code of Conduct, for a specified period of time. This
|
||||||
includes avoiding interactions in community spaces as well as external channels
|
includes avoiding interactions in community spaces as well as external channels
|
||||||
like social media. Violating these terms may lead to a temporary or
|
like social media. Violating these terms may lead to a temporary or permanent
|
||||||
permanent ban.
|
ban.
|
||||||
|
|
||||||
### 3. Temporary Ban
|
### 3. Temporary Ban
|
||||||
|
|
||||||
@@ -106,23 +106,27 @@ Violating these terms may lead to a permanent ban.
|
|||||||
### 4. Permanent Ban
|
### 4. Permanent Ban
|
||||||
|
|
||||||
**Community Impact**: Demonstrating a pattern of violation of community
|
**Community Impact**: Demonstrating a pattern of violation of community
|
||||||
standards, including sustained inappropriate behavior, harassment of an
|
standards, including sustained inappropriate behavior, harassment of an
|
||||||
individual, or aggression toward or disparagement of classes of individuals.
|
individual, or aggression toward or disparagement of classes of individuals.
|
||||||
|
|
||||||
**Consequence**: A permanent ban from any sort of public interaction within
|
**Consequence**: A permanent ban from any sort of public interaction within the
|
||||||
the community.
|
community.
|
||||||
|
|
||||||
## Attribution
|
## Attribution
|
||||||
|
|
||||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||||
version 2.0, available at
|
version 2.1, available at
|
||||||
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
||||||
|
|
||||||
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
Community Impact Guidelines were inspired by
|
||||||
enforcement ladder](https://github.com/mozilla/diversity).
|
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
||||||
|
|
||||||
[homepage]: https://www.contributor-covenant.org
|
|
||||||
|
|
||||||
For answers to common questions about this code of conduct, see the FAQ at
|
For answers to common questions about this code of conduct, see the FAQ at
|
||||||
https://www.contributor-covenant.org/faq. Translations are available at
|
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
||||||
https://www.contributor-covenant.org/translations.
|
[https://www.contributor-covenant.org/translations][translations].
|
||||||
|
|
||||||
|
[homepage]: https://www.contributor-covenant.org
|
||||||
|
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
||||||
|
[Mozilla CoC]: https://github.com/mozilla/diversity
|
||||||
|
[FAQ]: https://www.contributor-covenant.org/faq
|
||||||
|
[translations]: https://www.contributor-covenant.org/translations
|
||||||
|
|||||||
33
CONTRIBUTING.md
Normal file
33
CONTRIBUTING.md
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# How to contribute to Shortify Git Revision
|
||||||
|
|
||||||
|
## Did you find a bug
|
||||||
|
|
||||||
|
* **Do not open up a GitHub issue if the bug is a security vulnerability**, and instead to refer to our [security policy][1].
|
||||||
|
|
||||||
|
* **Ensure the bug was not already reported** by searching on GitHub under [Issues][2].
|
||||||
|
|
||||||
|
* If you're unable to find an open issue addressing the problem, [open a 'Bug' issue][4].
|
||||||
|
Be sure to include a **title and clear description**, as much relevant information as possible, and a **code sample** or an **executable test case** demonstrating the expected behavior that is not occurring.
|
||||||
|
|
||||||
|
## Did you write a patch that fixes a bug
|
||||||
|
|
||||||
|
* Open a new GitHub pull request with the patch.
|
||||||
|
|
||||||
|
* Ensure the PR description clearly describes the problem and solution.
|
||||||
|
Include the relevant issue number if applicable.
|
||||||
|
|
||||||
|
## Do you intend to add a new feature or change an existing one
|
||||||
|
|
||||||
|
* Suggest your change by [opening a 'Feature request' issue][5]
|
||||||
|
|
||||||
|
## Do you have questions about the source code
|
||||||
|
|
||||||
|
* [open an issue][3] with your question.
|
||||||
|
|
||||||
|
Thanks!
|
||||||
|
|
||||||
|
[1]: https://github.com/rlespinasse/shortify-git-revision/security/policy
|
||||||
|
[2]: https://github.com/rlespinasse/shortify-git-revision/issues
|
||||||
|
[3]: https://github.com/rlespinasse/shortify-git-revision/issues/new
|
||||||
|
[4]: https://github.com/rlespinasse/shortify-git-revision/issues/new?assignees=&labels=bug&template=bug_report.md&title=
|
||||||
|
[5]: https://github.com/rlespinasse/shortify-git-revision/issues/new?assignees=&labels=enhancement&template=feature_request.md&title=
|
||||||
86
README.md
86
README.md
@@ -1,18 +1,30 @@
|
|||||||
# Shortify git revision
|
# Shortify git revision
|
||||||
|
|
||||||
> Github Action to shortify a git revision
|
> [!NOTE]
|
||||||
|
> A GitHub Action that generates shortened Git revision identifiers from full-length commit hashes and exposes them as environment variables.
|
||||||
|
|
||||||
Produce short revision environment variable based on the input one.
|
## Features
|
||||||
|
|
||||||
If a revision is a bad revision, this action will produce an error message and fail depending on `continue-on-error` input value.
|
- Converts full Git revisions into their shortened form
|
||||||
`<NAME>`, and `<NAME>_SHORT` environment variable will only be available if the revision is not empty and valid.
|
- Validates revision format and handles invalid inputs
|
||||||
|
- Provides both full and shortened revisions as environment variables
|
||||||
|
- Configurable error handling for invalid revisions
|
||||||
|
|
||||||
|
## Behavior
|
||||||
|
|
||||||
|
- Creates `<NAME>` and `<NAME>_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
|
## Usage
|
||||||
|
|
||||||
- Shortify an environment variable
|
- Shortify an environment variable
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: rlespinasse/shortify-git-revision@v1.x
|
- uses: actions/checkout@v3
|
||||||
|
- uses: rlespinasse/shortify-git-revision@v1
|
||||||
with:
|
with:
|
||||||
name: GITHUB_SHA
|
name: GITHUB_SHA
|
||||||
```
|
```
|
||||||
@@ -24,7 +36,8 @@ If a revision is a bad revision, this action will produce an error message and f
|
|||||||
- Shortify an environment variable with prefix
|
- Shortify an environment variable with prefix
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: rlespinasse/shortify-git-revision@v1.x
|
- uses: actions/checkout@v3
|
||||||
|
- uses: rlespinasse/shortify-git-revision@v1
|
||||||
with:
|
with:
|
||||||
name: GITHUB_SHA
|
name: GITHUB_SHA
|
||||||
prefix: CI_
|
prefix: CI_
|
||||||
@@ -38,7 +51,8 @@ If a revision is a bad revision, this action will produce an error message and f
|
|||||||
- Shortify any revision
|
- Shortify any revision
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: rlespinasse/slugify-value@v1.x
|
- uses: actions/checkout@v3
|
||||||
|
- uses: rlespinasse/shortify-git-revision@v1
|
||||||
with:
|
with:
|
||||||
name: SOME_REVISION
|
name: SOME_REVISION
|
||||||
revision: 88428f56bd9d2751c47106bedfd148162dfa50b8
|
revision: 88428f56bd9d2751c47106bedfd148162dfa50b8
|
||||||
@@ -49,12 +63,42 @@ If a revision is a bad revision, this action will produce an error message and f
|
|||||||
- `SOME_REVISION`
|
- `SOME_REVISION`
|
||||||
- `SOME_REVISION_SHORT`
|
- `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
|
## Inputs
|
||||||
|
|
||||||
### `name`
|
### `name`
|
||||||
|
|
||||||
If used with `revision` input, it's the name of the environment variable containing the revision to shortify.
|
When providing a `revision` through the revision input, the action will use this environment variable name to store the shortened hash.
|
||||||
Otherwise, the `name` input will be used (in upper case) to define a environment variable containing the `revision` input value.
|
|
||||||
|
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`
|
### `revision`
|
||||||
|
|
||||||
@@ -68,8 +112,32 @@ If the input is set to `true`, this action will not fail on a bad revision
|
|||||||
|
|
||||||
The default value is `false`.
|
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`
|
### `prefix`
|
||||||
|
|
||||||
The value will be prepend to each generated variable.
|
The value will be prepend to each generated variable.
|
||||||
|
|
||||||
This input is _Optional_.
|
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 |
|
||||||
|
|||||||
22
SECURITY.md
Normal file
22
SECURITY.md
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# Security Policy
|
||||||
|
|
||||||
|
## Supported Versions and Branches
|
||||||
|
|
||||||
|
| Version | Supported | End of Support | Branch | Specific Tags |
|
||||||
|
| ------- | ------------------ | -------------- | ------ | ------------- |
|
||||||
|
| 1.x | :white_check_mark: | | v1.x | v1 |
|
||||||
|
|
||||||
|
A GitHub repository can use one of the available branches as an action inside its workflows.
|
||||||
|
|
||||||
|
### End of Life of a branch
|
||||||
|
|
||||||
|
Since `2024-10-26`, when a new major version is released,
|
||||||
|
|
||||||
|
- The previous one will continue to receive security patches for 3 months,
|
||||||
|
- After the 3 months, the branch is deleted, and only the tags remain.
|
||||||
|
|
||||||
|
## Reporting a Vulnerability
|
||||||
|
|
||||||
|
In this project, you can report a Vulnerability by creating a [draft security advisory](https://github.com/rlespinasse/shortify-git-revision/security/advisories).
|
||||||
|
|
||||||
|
If the vulnerability is confirmed, a fix will be produced and the advisory will be published.
|
||||||
31
action.yml
31
action.yml
@@ -1,6 +1,9 @@
|
|||||||
name: "Shortify Git Revision"
|
name: "Shortify Git Revision"
|
||||||
description: "Github Action to shortify a git revision"
|
description: "Github Action to shortify a git revision"
|
||||||
author: "Romain Lespinasse"
|
author: "Romain Lespinasse"
|
||||||
|
branding:
|
||||||
|
icon: "crop"
|
||||||
|
color: "gray-dark"
|
||||||
inputs:
|
inputs:
|
||||||
name:
|
name:
|
||||||
description: "Environment variable that will hold the value and serve as prefix to shortify value"
|
description: "Environment variable that will hold the value and serve as prefix to shortify value"
|
||||||
@@ -12,20 +15,40 @@ inputs:
|
|||||||
description: "Don't fail the action if the git revision isn't valid"
|
description: "Don't fail the action if the git revision isn't valid"
|
||||||
default: "false"
|
default: "false"
|
||||||
required: false
|
required: false
|
||||||
|
short-on-error:
|
||||||
|
description: "Still short it if the git revision isn't valid"
|
||||||
|
default: "false"
|
||||||
|
required: false
|
||||||
prefix:
|
prefix:
|
||||||
description: "Value to prepend to each generated variable"
|
description: "Value to prepend to each generated variable"
|
||||||
default: ""
|
default: ""
|
||||||
required: false
|
required: false
|
||||||
branding:
|
length:
|
||||||
icon: "crop"
|
description: "Value to configure the length of the shorted sha"
|
||||||
color: "gray-dark"
|
default: ""
|
||||||
|
required: false
|
||||||
|
publish-env:
|
||||||
|
description: "Publish short as environment variable"
|
||||||
|
default: "true"
|
||||||
|
required: false
|
||||||
|
outputs:
|
||||||
|
revision:
|
||||||
|
description: "The revision to be shortify"
|
||||||
|
value: ${{ steps.shortify.outputs.revision }}
|
||||||
|
short:
|
||||||
|
description: "Revision Short"
|
||||||
|
value: ${{ steps.shortify.outputs.short }}
|
||||||
runs:
|
runs:
|
||||||
using: "composite"
|
using: "composite"
|
||||||
steps:
|
steps:
|
||||||
- run: $GITHUB_ACTION_PATH/shortify.sh
|
- id: shortify
|
||||||
|
run: $GITHUB_ACTION_PATH/shortify.sh
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
INPUT_NAME: ${{ inputs.name }}
|
INPUT_NAME: ${{ inputs.name }}
|
||||||
INPUT_REVISION: ${{ inputs.revision }}
|
INPUT_REVISION: ${{ inputs.revision }}
|
||||||
INPUT_CONTINUE_ON_ERROR: ${{ inputs.continue-on-error }}
|
INPUT_CONTINUE_ON_ERROR: ${{ inputs.continue-on-error }}
|
||||||
|
INPUT_SHORT_ON_ERROR: ${{ inputs.short-on-error }}
|
||||||
INPUT_PREFIX: ${{ inputs.prefix }}
|
INPUT_PREFIX: ${{ inputs.prefix }}
|
||||||
|
INPUT_LENGTH: ${{ inputs.length }}
|
||||||
|
INPUT_PUBLISH_ENV: ${{ inputs.publish-env }}
|
||||||
|
|||||||
50
shortify.sh
50
shortify.sh
@@ -11,16 +11,52 @@ else
|
|||||||
fi
|
fi
|
||||||
REVISION=${INPUT_REVISION:-${!NAME}}
|
REVISION=${INPUT_REVISION:-${!NAME}}
|
||||||
|
|
||||||
if [ -z "$REVISION" ]; then
|
SHORT_LENGTH=""
|
||||||
|
if [ "${INPUT_LENGTH}" != "" ]; then
|
||||||
|
if [ "${INPUT_LENGTH}" -eq "${INPUT_LENGTH}" ] 2>/dev/null; then
|
||||||
|
SHORT_LENGTH="=${INPUT_LENGTH}"
|
||||||
|
elif [ "${INPUT_CONTINUE_ON_ERROR}" == "false" ]; then
|
||||||
|
echo "::error ::Invalid length: ${INPUT_LENGTH}, should be a number"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "::warning ::Invalid length: ${INPUT_LENGTH}, the default length will be used."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${REVISION}" ]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$(git cat-file -e "$REVISION" 2>&1)" == "" ]; then
|
SHORT_PUBLICATION=false
|
||||||
{
|
if [ "$(git cat-file -e "${REVISION}" 2>&1)" == "" ]; then
|
||||||
echo "${PREFIX}${NAME}=${REVISION}"
|
SHORT_VALUE=$(git rev-parse --short"${SHORT_LENGTH}" "${REVISION}")
|
||||||
echo "${PREFIX}${NAME}_SHORT=$(git rev-parse --short "$REVISION")"
|
SHORT_PUBLICATION="true"
|
||||||
} >>"$GITHUB_ENV"
|
elif [ "${INPUT_SHORT_ON_ERROR}" == "true" ]; then
|
||||||
|
if [ -n "${INPUT_LENGTH}" ]; then
|
||||||
|
SHORT_VALUE=$(cut -c1-"${INPUT_LENGTH}" <<<"${REVISION}")
|
||||||
|
SHORT_PUBLICATION="true"
|
||||||
|
else
|
||||||
|
echo "::error ::The input 'length' is mandatory with 'short-on-error' set to 'true'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
elif [ "${INPUT_CONTINUE_ON_ERROR}" == "false" ]; then
|
elif [ "${INPUT_CONTINUE_ON_ERROR}" == "false" ]; then
|
||||||
echo "::error ::Invalid revision: $REVISION from $NAME"
|
echo "::error ::Invalid revision: ${REVISION} from ${NAME}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "${SHORT_PUBLICATION}" == "true" ]; then
|
||||||
|
if [ -f "$GITHUB_OUTPUT" ]; then
|
||||||
|
echo "revision=${REVISION}" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "short=${SHORT_VALUE}" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "::set-output name=revision::${REVISION}"
|
||||||
|
echo "::set-output name=short::${SHORT_VALUE}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${INPUT_PUBLISH_ENV}" == "true" ]; then
|
||||||
|
{
|
||||||
|
echo "${PREFIX}${NAME}=${REVISION}"
|
||||||
|
echo "${PREFIX}${NAME}_SHORT=${SHORT_VALUE}"
|
||||||
|
} >>"$GITHUB_ENV"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user