diff --git a/README.md b/README.md index c6cf3cf..89549dd 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,9 @@ jobs: ### Optional +- `type`: Configure orientation for devcard + - `Vertical` (Default) + - `Horizontal` - `token`: GitHub Token used to commit the devcard - `commit_branch`: The branch to commit the devcard to. Defaults to the branch of the action. - `commit_message`: The commit message to use when committing the devcard. Defaults to `Update ${filename}`. diff --git a/action.yml b/action.yml index 38ed43a..c27b911 100644 --- a/action.yml +++ b/action.yml @@ -10,8 +10,8 @@ inputs: required: true type: - description: 'Configure orientation for devcard. Must be either "default" or "wide"' - default: default + description: 'Configure orientation for devcard. Must be either "Vertical" or "Horizontal"' + default: Vertical required: false token: diff --git a/src/index.ts b/src/index.ts index 6c96939..2f6782f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -13,9 +13,12 @@ process.on('unhandledRejection', (error) => { throw error }) -type DevCardType = 'default' | 'wide' +enum DevCardType { + Vertical = 'default', + Horizontal = 'wide', +} -const devcardURL = (user_id: string, type: DevCardType = 'default'): string => +const devcardURL = (user_id: string, type: DevCardType = DevCardType.Vertical): string => `https://api.daily.dev/devcards/v2/${user_id}.png?type=${type}&r=${new Date().valueOf()}&ref=action` ;(async function () { @@ -36,8 +39,8 @@ const devcardURL = (user_id: string, type: DevCardType = 'default'): string => } // throw an error if type is invalid, must be either "default" or "wide" - if (type && !['default', 'wide'].includes(type)) { - throw new Error('Invalid type. Must be either "default" or "wide"') + if (type && !Object.values(DevCardType).includes(type)) { + throw new Error('Invalid type') } console.log(`Dryrun`, dryrun)