1
1
import * as core from '@actions/core'
2
- import { getUserInfo , parseInputArray , readJSON } from './util'
2
+ import { getUserInfo , parseInputArray } from './util'
3
+
4
+ interface InputTypes {
5
+ add : string
6
+ author_name : string
7
+ author_email : string
8
+ branch : string | undefined
9
+ branch_mode : 'throw' | 'create'
10
+ commit : string | undefined
11
+ committer_name : string
12
+ committer_email : string
13
+ cwd : string
14
+ default_author : 'github_actor' | 'user_info' | 'github_actions'
15
+ message : string
16
+ pathspec_error_handling : 'ignore' | 'exitImmediately' | 'exitAtEnd'
17
+ pull : string | undefined
18
+ push : string
19
+ remove : string | undefined
20
+ tag : string | undefined
21
+
22
+ github_token : string | undefined
23
+ }
24
+ export type input = keyof InputTypes
25
+
26
+ interface OutputTypes {
27
+ committed : 'true' | 'false'
28
+ commit_sha : string | undefined
29
+ pushed : 'true' | 'false'
30
+ tagged : 'true' | 'false'
31
+ }
32
+ export type output = keyof OutputTypes
33
+
34
+ export const outputs : OutputTypes = {
35
+ committed : 'false' ,
36
+ commit_sha : undefined ,
37
+ pushed : 'false' ,
38
+ tagged : 'false'
39
+ }
40
+ // Setup default output values
41
+ Object . entries ( outputs ) . forEach ( ( [ name , value ] ) => core . setOutput ( name , value ) )
42
+
43
+ export function getInput < T extends input > ( name : T , parseAsBool : true ) : boolean
44
+ export function getInput < T extends input > (
45
+ name : T ,
46
+ parseAsBool ?: false
47
+ ) : InputTypes [ T ]
48
+ export function getInput < T extends input > (
49
+ name : T ,
50
+ parseAsBool = false
51
+ ) : InputTypes [ T ] | boolean {
52
+ if ( parseAsBool ) return core . getBooleanInput ( name )
53
+ // @ts -expect-error
54
+ return core . getInput ( name )
55
+ }
56
+
57
+ export function setOutput < T extends output > ( name : T , value : OutputTypes [ T ] ) {
58
+ core . debug ( `Setting output: ${ name } =${ value } ` )
59
+ outputs [ name ] = value
60
+ core . setOutput ( name , value )
61
+ }
62
+
63
+ export function logOutputs ( ) {
64
+ core . startGroup ( 'Outputs' )
65
+ for ( const key in outputs ) {
66
+ core . info ( `${ key } : ${ outputs [ key ] } ` )
67
+ }
68
+ core . endGroup ( )
69
+ }
3
70
4
71
export async function checkInputs ( ) {
5
72
function setInput ( input : input , value : string | undefined ) {
@@ -11,14 +78,6 @@ export async function checkInputs() {
11
78
return getInput ( input )
12
79
}
13
80
14
- const eventPath = process . env . GITHUB_EVENT_PATH ,
15
- event = eventPath && readJSON ( eventPath )
16
-
17
- const isPR = process . env . GITHUB_EVENT_NAME ?. includes ( 'pull_request' ) ,
18
- defaultBranch = isPR
19
- ? ( event ?. pull_request ?. head ?. ref as string )
20
- : process . env . GITHUB_REF ?. substring ( 11 )
21
-
22
81
// #region add, remove
23
82
if ( ! getInput ( 'add' ) && ! getInput ( 'remove' ) )
24
83
throw new Error (
@@ -138,12 +197,6 @@ export async function checkInputs() {
138
197
core . info ( `> Using "${ getInput ( 'message' ) } " as commit message.` )
139
198
// #endregion
140
199
141
- // #region branch
142
- const branch = setDefault ( 'branch' , defaultBranch || '' )
143
- if ( isPR )
144
- core . info ( `> Running for a PR, the action will use '${ branch } ' as ref.` )
145
- // #endregion
146
-
147
200
// #region branch_mode
148
201
const branch_mode_valid = [ 'throw' , 'create' ]
149
202
if ( ! branch_mode_valid . includes ( getInput ( 'branch_mode' ) ) )
@@ -168,11 +221,6 @@ export async function checkInputs() {
168
221
)
169
222
// #endregion
170
223
171
- // #region pull
172
- if ( getInput ( 'pull' ) == 'NO-PULL' )
173
- core . debug ( "NO-PULL found: won't pull from remote." )
174
- // #endregion
175
-
176
224
// #region push
177
225
if ( getInput ( 'push' ) ) {
178
226
// It has to be either 'true', 'false', or any other string (use as arguments)
@@ -195,70 +243,3 @@ export async function checkInputs() {
195
243
)
196
244
// #endregion
197
245
}
198
-
199
- interface InputTypes {
200
- add : string
201
- author_name : string
202
- author_email : string
203
- branch : string
204
- branch_mode : 'throw' | 'create'
205
- commit : string | undefined
206
- committer_name : string
207
- committer_email : string
208
- cwd : string
209
- default_author : 'github_actor' | 'user_info' | 'github_actions'
210
- message : string
211
- pathspec_error_handling : 'ignore' | 'exitImmediately' | 'exitAtEnd'
212
- pull : string | undefined
213
- push : string
214
- remove : string | undefined
215
- tag : string | undefined
216
-
217
- github_token : string | undefined
218
- }
219
- export type input = keyof InputTypes
220
-
221
- interface OutputTypes {
222
- committed : 'true' | 'false'
223
- commit_sha : string | undefined
224
- pushed : 'true' | 'false'
225
- tagged : 'true' | 'false'
226
- }
227
- export type output = keyof OutputTypes
228
-
229
- export const outputs : OutputTypes = {
230
- committed : 'false' ,
231
- commit_sha : undefined ,
232
- pushed : 'false' ,
233
- tagged : 'false'
234
- }
235
- // Setup default output values
236
- Object . entries ( outputs ) . forEach ( ( [ name , value ] ) => core . setOutput ( name , value ) )
237
-
238
- export function getInput < T extends input > ( name : T , parseAsBool : true ) : boolean
239
- export function getInput < T extends input > (
240
- name : T ,
241
- parseAsBool ?: false
242
- ) : InputTypes [ T ]
243
- export function getInput < T extends input > (
244
- name : T ,
245
- parseAsBool = false
246
- ) : InputTypes [ T ] | boolean {
247
- if ( parseAsBool ) return core . getBooleanInput ( name )
248
- // @ts -expect-error
249
- return core . getInput ( name )
250
- }
251
-
252
- export function setOutput < T extends output > ( name : T , value : OutputTypes [ T ] ) {
253
- core . debug ( `Setting output: ${ name } =${ value } ` )
254
- outputs [ name ] = value
255
- core . setOutput ( name , value )
256
- }
257
-
258
- export function logOutputs ( ) {
259
- core . startGroup ( 'Outputs' )
260
- for ( const key in outputs ) {
261
- core . info ( `${ key } : ${ outputs [ key ] } ` )
262
- }
263
- core . endGroup ( )
264
- }
0 commit comments