Skip to content

Commit 51a7a2d

Browse files
authored
feat: Add commit-sha output to the commit action (#294)
1 parent bc89f97 commit 51a7a2d

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

commit/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ steps:
2929
- `branch` (optional, default `${{ github.head_ref || github.ref_name }}`) — Target branch name. On pull requests this resolves to the PR's source branch (`github.head_ref`); on other events it resolves to `github.ref_name`. Required when `create-branch` is `true`.
3030
- `create-branch` (optional, default `false`) — When `true`, the action pushes `HEAD` to `branch` as a new remote branch before committing. `branch` must be passed explicitly in this case.
3131

32+
### Outputs
33+
34+
- `commit-sha` — The SHA of the created commit.
35+
3236
### Example: commit to a new branch
3337

3438
```yaml

commit/action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ inputs:
2020
default: 'false'
2121
required: false
2222

23+
outputs:
24+
commit-sha:
25+
description: 'The SHA of the created commit.'
26+
value: ${{ steps.commit.outputs.commit-sha }}
27+
2328
runs:
2429
using: composite
2530
steps:
@@ -50,6 +55,7 @@ runs:
5055
run: echo "head_ref=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
5156

5257
- name: Commit through API
58+
id: commit
5359
uses: actions/github-script@v8
5460
env:
5561
COMMIT_MESSAGE: ${{ inputs.commit-message }}

0 commit comments

Comments
 (0)