Skip to content

Commit 087fec7

Browse files
authored
Merge pull request #14 from jaychang99/release/v0.2.1-beta
Release/v0.2.1 beta
2 parents 788a225 + 69f7c3d commit 087fec7

File tree

8 files changed

+92
-15
lines changed

8 files changed

+92
-15
lines changed

.github/PULL_REQUEST_TEMPLATE.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# 0.2.1-beta (July 1, 2024)
2+
3+
Below is a list of all new features, APIs, deprecations, and breaking changes.
4+
5+
## New Features
6+
7+
-
8+
9+
## Improvements
10+
11+
-
12+
13+
## Other Changes
14+
15+
-
16+
17+
## Bug Fixes
18+
19+
-

action.yml

+29-1
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,37 @@ branding:
1010
# Define your inputs here.
1111
inputs:
1212
milliseconds:
13-
description: 'Your input description here'
13+
description: 'The number of milliseconds to wait before the action starts. '
1414
required: true
1515
default: '1000'
16+
slack_enabled:
17+
description: 'Enable Slack notifications'
18+
required: false
19+
default: 'false'
20+
slack_channel_id:
21+
description: 'The Slack channel ID to send notifications to'
22+
slack_access_token:
23+
description:
24+
'The Slack access token that has the necessary permissions to send
25+
messages to the channel'
26+
locale:
27+
description: 'The locale to use for the action'
28+
required: false
29+
default: 'en-us'
30+
member_id_list_to_mention:
31+
description:
32+
'A list of member IDs to mention in the Slack message, comma separated'
33+
api_documentation_url:
34+
description: 'The URL to the API documentation'
35+
required: false
36+
openapi_file_path:
37+
description: 'The path to the OpenAPI file'
38+
required: false
39+
default: 'openapi.json'
40+
head_commit_message:
41+
description: 'The message of the head commit'
42+
head_commit_sha:
43+
description: 'The SHA of the head commit'
1644

1745
# Define your outputs here.
1846
outputs:

badges/coverage.svg

+1-1
Loading

dist/index.js

+13-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/types/github-input.ts

+5
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ export interface GithubInput {
3939
*/
4040
headCommitMessage?: string
4141

42+
/**
43+
* The sha of the last commit which triggered the action
44+
*/
45+
headCommitSha?: string
46+
4247
/**
4348
* URL of the api documentation - Optional
4449
*/

src/utils/get-file-from-branch.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
import { execSync } from 'child_process'
22
import { readFileSync } from 'fs'
33

4-
export function getFileFromBranch(branch: string, filePath: string): Buffer {
4+
export function getFileFromBranch(
5+
branch: string,
6+
filePath: string,
7+
offsetFromHead?: number
8+
): Buffer {
9+
const offset = offsetFromHead ? `~${offsetFromHead}` : ''
10+
511
execSync(`git fetch origin ${branch}`)
6-
execSync(`git checkout FETCH_HEAD -- ${filePath}`)
12+
execSync(`git checkout FETCH_HEAD${offset} -- ${filePath}`)
713
return readFileSync(filePath)
814
}

src/utils/validate-input.ts

+16-4
Original file line numberDiff line numberDiff line change
@@ -99,23 +99,35 @@ export function validateInputAndSetConfig(): Config {
9999
const baseCommittish = isOnPullRequest
100100
? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
101101
process.env.GITHUB_BASE_REF!
102-
: `${headCommittish}~1`
102+
: headCommittish
103103

104+
// core.getInput() always returns a string, so nullish coalescing operator does not work.
104105
const openapiFilePath =
105-
core.getInput('openapi_file_path') ?? DEFAULT_OPENAPI_FILE_PATH
106+
core.getInput('openapi_file_path') === ''
107+
? DEFAULT_OPENAPI_FILE_PATH
108+
: core.getInput('openapi_file_path')
106109

107110
baseFile = JSON.parse(
108-
getFileFromBranch(baseCommittish, openapiFilePath).toString()
111+
getFileFromBranch(
112+
baseCommittish,
113+
openapiFilePath,
114+
isOnPullRequest ? undefined : 1
115+
).toString()
109116
)
110117
headFile = JSON.parse(
111118
getFileFromBranch(headCommittish, openapiFilePath).toString()
112119
)
113120
}
114121

122+
const sha =
123+
core.getInput('head_commit_sha') === ''
124+
? MOCKUP_SHA
125+
: core.getInput('head_commit_sha')
126+
115127
const githubConfig: Config['githubConfig'] = {
116128
repository: process.env.GITHUB_REPOSITORY ?? MOCKUP_REPOSITORY,
117129
headCommitInfo: {
118-
sha: process.env.GITHUB_SHA ?? MOCKUP_SHA,
130+
sha,
119131
message:
120132
core.getInput('head_commit_message') === ''
121133
? MOCKUP_MESSAGE

0 commit comments

Comments
 (0)