Skip to content

Commit 608f2a0

Browse files
get files from last commit
1 parent 2674592 commit 608f2a0

File tree

4 files changed

+28
-18
lines changed

4 files changed

+28
-18
lines changed

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ branding:
55
icon: align-center
66
color: purple
77
inputs:
8+
github-token:
9+
description: 'Location to blog markdown files.'
10+
required: true
811
content-dir:
912
description: 'Location to blog markdown files.'
1013
required: true

dist/index.js

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

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,23 @@ import * as core from '@actions/core'
22
import * as github from '@actions/github'
33
import * as Webhooks from '@octokit/webhooks'
44

5+
const getFiles = async (): Promise<string[]> => {
6+
const octokit = github.getOctokit(core.getInput('github-token'))
7+
const commit = await octokit.repos.getCommit({
8+
...github.context.repo,
9+
ref: github.context.sha
10+
})
11+
12+
return (commit?.data?.files || [])
13+
.map((file: any) => file.filename)
14+
.filter((filename: string) =>
15+
filename.includes(core.getInput('content-dir'))
16+
)
17+
}
18+
519
async function run(): Promise<void> {
620
try {
7-
const octokit = github.getOctokit(core.getInput('github-token'))
8-
const commit = await octokit.repos.getCommit({
9-
...github.context.repo,
10-
ref: github.context.sha
11-
})
12-
const files = (commit?.data?.files || [])
13-
.map((file: any) => file.filename)
14-
.filter((filename: string) =>
15-
filename.includes(core.getInput('content-dir'))
16-
)
17-
21+
const files = await getFiles()
1822
files.forEach(file => console.log(`File: ${file}`))
1923
} catch (error) {
2024
core.setFailed(error.message)

0 commit comments

Comments
 (0)