Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(params): Add customisable committer params #377

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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