Add commit_sha output (#275)
* feat: add commit_sha output * docs(README): add docs for commit_sha
This commit is contained in:
@@ -130,6 +130,7 @@ If you're getting this error and you're using `actions/checkout@v1`, try upgradi
|
|||||||
The action provides these outputs:
|
The action provides these outputs:
|
||||||
|
|
||||||
- `committed`: whether the action has created a commit (`'true'` or `'false'`)
|
- `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'`)
|
- `pushed`: whether the action has pushed to the remote (`'true'` or `'false'`)
|
||||||
- `tagged`: whether the action has created a tag (`'true'` or `'false'`)
|
- `tagged`: whether the action has created a tag (`'true'` or `'false'`)
|
||||||
|
|
||||||
@@ -164,7 +165,6 @@ You can also use the `committer_name` and `committer_email` inputs to make it ap
|
|||||||
committer_email: actions@github.com
|
committer_email: actions@github.com
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
<img src="https://user-images.githubusercontent.com/26386270/130594443-b881fae7-3064-4020-a4cc-6db37ef0df65.png" height=70/>
|
<img src="https://user-images.githubusercontent.com/26386270/130594443-b881fae7-3064-4020-a4cc-6db37ef0df65.png" height=70/>
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
@@ -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
|
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:
|
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
|
```yaml
|
||||||
@@ -238,8 +237,6 @@ jobs:
|
|||||||
cwd: './pathToRepo/'
|
cwd: './pathToRepo/'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Contributors ✨
|
## Contributors ✨
|
||||||
|
|
||||||
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
||||||
|
|||||||
@@ -59,6 +59,8 @@ inputs:
|
|||||||
outputs:
|
outputs:
|
||||||
committed:
|
committed:
|
||||||
description: Whether the action has created a commit.
|
description: Whether the action has created a commit.
|
||||||
|
commit_sha:
|
||||||
|
description: The SHA of the commit that has been created.
|
||||||
pushed:
|
pushed:
|
||||||
description: Whether the action has pushed to the remote.
|
description: Whether the action has pushed to the remote.
|
||||||
tagged:
|
tagged:
|
||||||
|
|||||||
4
lib/index.js
generated
4
lib/index.js
generated
File diff suppressed because one or more lines are too long
@@ -1,6 +1,6 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import simpleGit, { Response } from 'simple-git'
|
import simpleGit, { CommitSummary, Response } from 'simple-git'
|
||||||
import YAML from 'js-yaml'
|
import YAML from 'js-yaml'
|
||||||
import {
|
import {
|
||||||
getInput,
|
getInput,
|
||||||
@@ -85,8 +85,11 @@ core.info(`Running in ${baseDir}`)
|
|||||||
}
|
}
|
||||||
: {})
|
: {})
|
||||||
},
|
},
|
||||||
(err, data?) => {
|
(err, data?: CommitSummary) => {
|
||||||
if (data) setOutput('committed', 'true')
|
if (data) {
|
||||||
|
setOutput('committed', 'true')
|
||||||
|
setOutput('commit_sha', data.commit)
|
||||||
|
}
|
||||||
return log(err, data)
|
return log(err, data)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ export type Input =
|
|||||||
| 'tag'
|
| 'tag'
|
||||||
| 'github_token'
|
| '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>
|
type RecordOf<T extends string> = Record<T, string | undefined>
|
||||||
export const tools = new Toolkit<RecordOf<Input>, RecordOf<Output>>({
|
export const tools = new Toolkit<RecordOf<Input>, RecordOf<Output>>({
|
||||||
@@ -31,8 +31,9 @@ export const tools = new Toolkit<RecordOf<Input>, RecordOf<Output>>({
|
|||||||
'GITHUB_ACTOR'
|
'GITHUB_ACTOR'
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export const outputs: Record<Output, 'true' | 'false'> = {
|
export const outputs: Record<Output, any> = {
|
||||||
committed: 'false',
|
committed: 'false',
|
||||||
|
commit_sha: undefined,
|
||||||
pushed: 'false',
|
pushed: 'false',
|
||||||
tagged: 'false'
|
tagged: 'false'
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user