Skip to content

Commit

Permalink
feat(params): Add customisable committer params
Browse files Browse the repository at this point in the history
  • Loading branch information
centrumek committed Oct 10, 2023
1 parent 53ddfc8 commit 00f7f24
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ jobs:
- You can use `${filename}` in the message to refer to the filename of the devcard.
- `commit_filename`: The filename to commit the devcard to. Defaults to `devcard.svg`.
- If you want to save the devcard as a PNG, you can use `devcard.png` instead, or any other filename ending in `.png`.
- `committer_email`: The committer email used in commit. Defaults to `noreply@github.com`.
- `committer_name`: The committer name used in commit. Defaults to `github-actions[bot]`.
- `dryrun`: If set to `true`, the action will run as normal, but not actually commit the devcard

## Advanced usage
Expand Down
10 changes: 10 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ inputs:
default: devcard.svg
required: false

committer_email:
description: Committer email
default: 41898282+github-actions[bot]@users.noreply.github.com
required: false

committer_name:
description: Committer name
default: github-actions[bot]
required: false

dryrun:
description: 'If true, no changes will be made to the repo'
default: false
Expand Down
5 changes: 5 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ const validateDevcardIdAsUUID = (devcard_id: string): boolean => {
const branch = core.getInput('commit_branch')
const message = core.getInput('commit_message')
const filename = core.getInput('commit_filename')
const email = core.getInput('committer_email')
const name = core.getInput('committer_name')
const dryrun = core.getBooleanInput('dryrun')

// throw an error if filename is empty
Expand Down Expand Up @@ -103,6 +105,8 @@ const validateDevcardIdAsUUID = (devcard_id: string): boolean => {
message: message.replace(/[$][{]filename[}]/g, filename),
branch: branch || github.context.ref.replace(/^refs[/]heads[/]/, ''),
sha: undefined,
email: email,
name: name,
}

const octokit = github.getOctokit(token)
Expand Down Expand Up @@ -177,6 +181,7 @@ const validateDevcardIdAsUUID = (devcard_id: string): boolean => {
message: committer.message,
content: fileContent.toString('base64'),
branch: committer.branch,
committer: { name: committer.name, email: committer.email },
...(committer.sha ? { sha: committer.sha } : {}),
})
}
Expand Down

0 comments on commit 00f7f24

Please sign in to comment.