Skip to content

Commit 18bf3de

Browse files
committed
feat: support description
1 parent a8becd7 commit 18bf3de

File tree

6 files changed

+20
-6
lines changed

6 files changed

+20
-6
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,6 @@ jobs:
5050
with:
5151
token: ${{ secrets.TOKEN }}
5252
gist_id: e885afa349a0e5d1cfb408e46d6a37bc
53+
gist_description: "foo bar"
5354
gist_file_name: foo.bar
5455
file_path: ./__tests__/foo.bar

__tests__/index.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ import { getInput } from '../src/input'
55

66
test('input', () => {
77
process.env.INPUT_GIST_ID = 'gist_id'
8+
process.env.INPUT_GIST_DESCRIPTION = 'gist_description'
89
process.env.INPUT_GIST_FILE_NAME = 'gist_file_name'
910
process.env.INPUT_FILE_PATH = 'file_path'
1011

1112
const input = getInput()
1213

1314
expect(input.token).toMatch('')
1415
expect(input.gistId).toMatch('gist_id')
16+
expect(input.gistDescription).toMatch('gist_description')
1517
expect(input.gistFileName).toMatch('gist_file_name')
1618
expect(input.filePath).toMatch('file_path')
1719
})
@@ -20,6 +22,7 @@ test('run', () => {
2022
process.env.GITHUB_WORKSPACE = process.cwd()
2123
dotenv.config()
2224
process.env.INPUT_GIST_ID = 'e885afa349a0e5d1cfb408e46d6a37bc'
25+
process.env.INPUT_GIST_DESCRIPTION = 'foo bar'
2326
process.env.INPUT_GIST_FILE_NAME = 'foo.bar'
2427
process.env.INPUT_FILE_PATH = '__tests__/foo.bar'
2528

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ inputs:
1111
gist_id:
1212
required: true
1313
description: "Set id of the gist to be updated."
14+
gist_description:
15+
required: false
16+
description: "Set description of the gist."
1417
gist_file_name:
1518
required: false
1619
description: "Set file name in the gist."

dist/index.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/input.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
import { getInput as getActionInput } from '@actions/core'
22

3-
interface Input {
4-
readonly token: string
5-
readonly gistId: string
6-
readonly gistFileName?: string
7-
readonly filePath: string
8-
}
3+
type Input = Readonly<{
4+
token: string
5+
gistId: string
6+
gistDescription?: string
7+
gistFileName?: string
8+
filePath: string
9+
}>
910

1011
export const getInput = (): Input => {
1112
return {
1213
token: getActionInput('token'),
1314
gistId: getActionInput('gist_id'),
15+
gistDescription: getActionInput('gist_description'),
1416
gistFileName: getActionInput('gist_file_name'),
1517
filePath: getActionInput('file_path')
1618
}

src/run.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export const run = async (): Promise<void> => {
1010
startGroup('Dump inputs')
1111
info(`\
1212
[INFO] GistId: ${input.gistId}
13+
[INFO] GistDescription: ${input.gistDescription}
1314
[INFO] GistFileName: ${input.gistFileName ?? 'No Change'}
1415
[INFO] FilePath: ${input.filePath}`)
1516
endGroup()
@@ -26,6 +27,7 @@ export const run = async (): Promise<void> => {
2627
const fileName = input.gistFileName ?? path.basename(filePath)
2728
await octokit.rest.gists.update({
2829
gist_id: input.gistId,
30+
description: input.gistDescription,
2931
files: {
3032
[fileName]: {
3133
fileName,

0 commit comments

Comments
 (0)