Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add commit_sha output #275

Merged
merged 2 commits into from
Aug 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ If you're getting this error and you're using `actions/checkout@v1`, try upgradi
The action provides these outputs:

- `committed`: whether the action has created a commit (`'true'` or `'false'`)
- `commit_sha`: the short 7-digit sha of the commit that has just been created
- `pushed`: whether the action has pushed to the remote (`'true'` or `'false'`)
- `tagged`: whether the action has created a tag (`'true'` or `'false'`)

Expand Down Expand Up @@ -164,7 +165,6 @@ You can also use the `committer_name` and `committer_email` inputs to make it ap
committer_email: [email protected]
```


<img src="https://user-images.githubusercontent.com/26386270/130594443-b881fae7-3064-4020-a4cc-6db37ef0df65.png" height=70/>

```yaml
Expand All @@ -175,7 +175,6 @@ You can also use the `committer_name` and `committer_email` inputs to make it ap
committer_email: 41898282+github-actions[bot]@users.noreply.github.com
```


Do you want to lint your JavaScript files, located in the `src` folder, with ESLint, so that fixable changes are done without your intervention? You can use a workflow like this:

```yaml
Expand Down Expand Up @@ -238,8 +237,6 @@ jobs:
cwd: './pathToRepo/'
```



## Contributors ✨

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
Expand Down
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ inputs:
outputs:
committed:
description: Whether the action has created a commit.
commit_sha:
description: The SHA of the commit that has been created.
pushed:
description: Whether the action has pushed to the remote.
tagged:
Expand Down
4 changes: 2 additions & 2 deletions lib/index.js

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as core from '@actions/core'
import path from 'path'
import simpleGit, { Response } from 'simple-git'
import simpleGit, { CommitSummary, Response } from 'simple-git'
import YAML from 'js-yaml'
import {
getInput,
Expand Down Expand Up @@ -85,8 +85,11 @@ core.info(`Running in ${baseDir}`)
}
: {})
},
(err, data?) => {
if (data) setOutput('committed', 'true')
(err, data?: CommitSummary) => {
if (data) {
setOutput('committed', 'true')
setOutput('commit_sha', data.commit)
}
return log(err, data)
}
)
Expand Down
5 changes: 3 additions & 2 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export type Input =
| 'tag'
| 'github_token'

export type Output = 'committed' | 'pushed' | 'tagged'
export type Output = 'committed' | 'commit_sha' | 'pushed' | 'tagged'

type RecordOf<T extends string> = Record<T, string | undefined>
export const tools = new Toolkit<RecordOf<Input>, RecordOf<Output>>({
Expand All @@ -31,8 +31,9 @@ export const tools = new Toolkit<RecordOf<Input>, RecordOf<Output>>({
'GITHUB_ACTOR'
]
})
export const outputs: Record<Output, 'true' | 'false'> = {
export const outputs: Record<Output, any> = {
committed: 'false',
commit_sha: undefined,
pushed: 'false',
tagged: 'false'
}
Expand Down