Skip to content

Commit

Permalink
feat: onboard git-commit-metadata composite action
Browse files Browse the repository at this point in the history
  • Loading branch information
piyoki committed Dec 30, 2023
1 parent 79e3296 commit 144258e
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/run-unit-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: vertexbox/github-seed-actions/git/git-revision-count/test@master

git-git-commit-metadata-unit-test:
runs-on: ubuntu-latest
steps:
- uses: vertexbox/github-seed-actions/git/git-commit-metadata/test@master
38 changes: 38 additions & 0 deletions git/git-commit-metadata/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Git Commit Metadata Action

A GitHub Action to retrieve the metadata associated with the given git commit.

## Inputs

```yaml
inputs:
repository:
required: true
type: string
ref:
required: true
type: string
fetch-depth:
required: false
type: string
default: 0
```
## Outputs
```yaml
outputs:
git_sha_long: ${{ steps.metadata.outputs.git_sha_long }}
git_sha_short: ${{ steps.metadata.outputs.git_sha_short }}
git_commit_msg: ${{ steps.metadata.outputs.git_commit_msg }}
```
## Example workflow
```yml
steps:
```
## License
All composite actions and unit tests in this project are released under the [MIT License](../../LICENSE)
47 changes: 47 additions & 0 deletions git/git-commit-metadata/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# _ _
# __ _____ _ __| |_ _____ _| |__ _____ __
# \ \ / / _ \ '__| __/ _ \ \/ / '_ \ / _ \ \/ /
# \ V / __/ | | || __/> <| |_) | (_) > <
# \_/ \___|_| \__\___/_/\_\_.__/ \___/_/\_\
#
#
# Copyright (C) 2023-2024 @vertexbox <https://github.com/vertexbox>
#
# This is a open-source software, licensed under the MIT License.
# See /License for more information.

name: Get git commit metadata
description: "get the metadata associated to a specific git commit"

inputs:
repository:
required: true
type: string
ref:
required: true
type: string
fetch-depth:
required: false
type: string
default: 0

outputs:
git_sha_long: ${{ steps.metadata.outputs.git_sha_long }}
git_sha_short: ${{ steps.metadata.outputs.git_sha_short }}
git_commit_msg: ${{ steps.metadata.outputs.git_commit_msg }}

runs:
using: composite
steps:
- uses: actions/checkout@master
with:
repository: ${{ inputs.repository }}
ref: ${{ inputs.ref }}

- name: Get metadata associated to the given ref
id: metadata
run: |
echo "git_sha_long=${{ inputs.ref }}" >> $GITHUB_OUTPUT
echo "git_sha_short=$(echo ${{ inputs.ref }} | cut -c1-6)" >> $GITHUB_OUTPUT
echo "git_commit_msg=$(git log --format=%s -n 1 ${{ inputs.ref }})" >> $GITHUB_OUTPUT
shell: bash
36 changes: 36 additions & 0 deletions git/git-commit-metadata/test/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# _ _
# __ _____ _ __| |_ _____ _| |__ _____ __
# \ \ / / _ \ '__| __/ _ \ \/ / '_ \ / _ \ \/ /
# \ V / __/ | | || __/> <| |_) | (_) > <
# \_/ \___|_| \__\___/_/\_\_.__/ \___/_/\_\
#
#
# Copyright (C) 2023-2024 @vertexbox <https://github.com/vertexbox>
#
# This is a open-source software, licensed under the MIT License.
# See /License for more information.

name: git-revision-count unit test
description: Test git-revision-count composite action

runs:
using: composite
steps:
- uses: actions/checkout@master
with:
fetch-depth: 0

- name: git-commit-metadata
id: metadata
uses: vertexbox/github-seed-actions/git/git-commit-metadata@master
with:
repository: ${{ github.repository }}
# ref: ${{ github.event.pull_request.head.sha }} # pr
ref: ${{ github.sha }} # default_branch (master|main|develop)

- name: git-revision-count
run: |
echo ${{ steps.metadata.outputs.git_sha_long }}
echo ${{ steps.metadata.outputs.git_sha_short }}
echo ${{ steps.metadata.outputs.git_commit_msg }}
shell: bash
6 changes: 2 additions & 4 deletions git/git-revision-count/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Git Revision Count Action

A GitHub Action for retrieve the total number of revision based on a given git ref.
A GitHub Action to retrieve the total number of revision based on a given git ref.

## Inputs

Expand All @@ -21,8 +21,6 @@ outputs:
value: ${{ steps.rev_count.outputs.count }}
```
Description: The number of revisions based on the given git ref
## Example workflow
```yml
Expand All @@ -35,7 +33,7 @@ steps:
id: git_rev_count
uses: vertexbox/github-seed-actions/git/git-revision-count@master
with:
ref: ${{ github.ref }}
ref: ${{ github.ref }}

- name: git-revision-count
run: |
Expand Down

0 comments on commit 144258e

Please sign in to comment.