@@ -13,12 +13,18 @@ process.on('unhandledRejection', (error) => {
13
13
throw error
14
14
} )
15
15
16
- const devcardURL = ( user_id : string ) : string =>
17
- `https://api.daily.dev/devcards/v2/${ user_id } .png?r=${ new Date ( ) . valueOf ( ) } &ref=action`
16
+ enum DevCardType {
17
+ Vertical = 'default' ,
18
+ Horizontal = 'wide' ,
19
+ }
20
+
21
+ const devcardURL = ( user_id : string , type : DevCardType = DevCardType . Vertical ) : string =>
22
+ `https://api.daily.dev/devcards/v2/${ user_id } .png?type=${ type } &r=${ new Date ( ) . valueOf ( ) } &ref=action`
18
23
19
24
; ( async function ( ) {
20
25
try {
21
26
const user_id = core . getInput ( 'user_id' )
27
+ const type = core . getInput ( 'type' ) as DevCardType
22
28
const token = core . getInput ( 'token' )
23
29
const branch = core . getInput ( 'commit_branch' )
24
30
const message = core . getInput ( 'commit_message' )
@@ -32,13 +38,18 @@ const devcardURL = (user_id: string): string =>
32
38
throw new Error ( 'Filename is required' )
33
39
}
34
40
41
+ // throw an error if type is invalid, must be either "default" or "wide"
42
+ if ( type && ! Object . values ( DevCardType ) . includes ( type ) ) {
43
+ throw new Error ( 'Invalid type' )
44
+ }
45
+
35
46
console . log ( `Dryrun` , dryrun )
36
47
37
48
// Fetch the latest devcard
38
49
try {
39
- const { body } = await fetch ( devcardURL ( user_id ) )
50
+ const { body } = await fetch ( devcardURL ( user_id , type ) )
40
51
if ( body === null ) {
41
- const message = `Empty response from devcard URL: ${ devcardURL ( user_id ) } `
52
+ const message = `Empty response from devcard URL: ${ devcardURL ( user_id , type ) } `
42
53
core . setFailed ( message )
43
54
console . debug ( message )
44
55
process . exit ( 1 )
0 commit comments