Skip to content

Commit a0edb11

Browse files
committed
refactor: destructure input
1 parent 01ed8e5 commit a0edb11

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

dist/index.js

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

src/run.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { createTempDirectory } from './utils'
88

99
export const run = async (): Promise<void> => {
1010
const input = getInput()
11+
const { token, gistId, gistDescription } = input
1112

1213
const workspace = process.env.GITHUB_WORKSPACE!
1314
const filePath = join(workspace, input.filePath)
@@ -17,8 +18,8 @@ export const run = async (): Promise<void> => {
1718

1819
startGroup('Dump inputs')
1920
info(`\
20-
[INFO] GistId: ${input.gistId}${
21-
input.gistDescription === undefined ? '' : `\n[INFO] GistDescription: ${input.gistDescription}`
21+
[INFO] GistId: ${gistId}${
22+
gistDescription === undefined ? '' : `\n[INFO] GistDescription: ${gistDescription}`
2223
}
2324
[INFO] GistFileName: ${fileName}
2425
[INFO] FilePath: ${input.filePath}
@@ -28,10 +29,10 @@ export const run = async (): Promise<void> => {
2829
startGroup('Deploy to gist')
2930
if (fileType === 'text') {
3031
const content = await fs.readFile(filePath, 'utf-8')
31-
const octokit = getOctokit(input.token)
32+
const octokit = getOctokit(token)
3233
await octokit.rest.gists.update({
33-
gist_id: input.gistId,
34-
description: input.gistDescription,
34+
gist_id: gistId,
35+
description: gistDescription,
3536
files: {
3637
[fileName]: {
3738
fileName,
@@ -42,7 +43,7 @@ export const run = async (): Promise<void> => {
4243
} else {
4344
const git = simpleGit()
4445
const gistDir = await createTempDirectory()
45-
await git.clone(`https://${input.token}@gist.github.com/${input.gistId}.git`, gistDir)
46+
await git.clone(`https://${token}@gist.github.com/${gistId}.git`, gistDir)
4647
await git.cwd(gistDir)
4748
await git.addConfig('user.name', process.env.GITHUB_ACTOR!)
4849
await git.addConfig('user.email', `${process.env.GITHUB_ACTOR}@users.noreply.github.com`)
@@ -52,7 +53,7 @@ export const run = async (): Promise<void> => {
5253
const branch = await git.revparse(['--abbrev-ref', 'HEAD'])
5354
await git.push('origin', branch)
5455
}
55-
info(`[INFO] Done with gist "${input.gistId}/${fileName}"`)
56+
info(`[INFO] Done with gist "${gistId}/${fileName}"`)
5657
endGroup()
5758

5859
info('[INFO] Action successfully completed')

0 commit comments

Comments
 (0)