Skip to content

Commit

Permalink
feat: make tracker inputs optional
Browse files Browse the repository at this point in the history
  • Loading branch information
jamacku committed Jun 21, 2024
1 parent 0457c99 commit 85d2b14
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 25 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,14 @@ Path to configuration file. Configuration file format is described in: [Configur
The tracker identificator. For example, for Bugzilla: `tracker: 1234567`.

* default value: `undefined`
* requirements: `required`
* requirements: `optional`

### tracker-type

The tracker type. Currently supported: `bugzilla` and `jira`.
The tracker type. Currently supported: `bugzilla`, `jira`, and `none`. When defined, then also `tracker` input has to be defined.

* default value: `undefined`
* requirements: `required`
* default value: `none`
* requirements: `optional`

### bugzilla-instance

Expand Down
9 changes: 5 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ inputs:
required: true
description: Pull Request metadata
config-path:
required: true
required: false
default: .github/auto-merge.yml
description: Path to configuration file

tracker:
required: true
required: false
description: tracker ID
tracker-type:
required: true
required: false
default: 'none'
description: tracker type, supported values are 'bugzilla' and 'jira'

bugzilla-instance:
Expand All @@ -36,7 +37,7 @@ inputs:
description: Jira API TOKEN

set-status:
required: true
required: false
default: 'false'
description: Set check-run status on Pull Request
status-title:
Expand Down
103 changes: 103 additions & 0 deletions dist/action.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/action.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 12 additions & 5 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"package": "ncc build --source-map --license licenses.txt",
"test": "vitest run --coverage",
"update-snapshots": "vitest run --update",
"all": "yarn run build && yarn run format && yarn run lint && yarn run package && yarn test"
"all": "yarn run build && yarn run format && yarn run package && yarn test"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -48,4 +48,4 @@
"typescript": "^5.5.2",
"vitest": "^1.6.0"
}
}
}
28 changes: 19 additions & 9 deletions src/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ async function action(
repo: string,
pr: PullRequest
): Promise<string> {
const trackerType = getInput('tracker-type', { required: true });
const trackerType = getInput('tracker-type');
const config = await Config.getConfig(octokit);

let trackerController: Controller<Bugzilla | Jira>;
let trackerController: Controller<Bugzilla | Jira> | undefined = undefined;

switch (trackerType) {
case 'bugzilla':
Expand All @@ -46,6 +46,10 @@ async function action(
);
break;

case 'none':
debug(`No tracker specified`);
break;

default:
raise(
`🔴 Missing tracker or Unknown tracker type; type: '${trackerType}'`
Expand All @@ -56,8 +60,10 @@ async function action(
let err: string[] = [];
let labels: { add: string[] } = { add: [] };

const tracker = getInput('tracker', { required: true });
await trackerController.adapter.getIssueDetails(tracker);
if (trackerController) {
const tracker = getInput('tracker', { required: true });
await trackerController.adapter.getIssueDetails(tracker);
}

if (pr.draft || pr.currentLabels.includes(config.labels['dont-merge'])) {
err.push(
Expand Down Expand Up @@ -137,11 +143,15 @@ async function action(

if (isMerged) {
debug(`Pull Request was merged`);
await trackerController.adapter.addMergeComment(
pr.title,
pr.targetBranch,
pr.url
);

if (trackerController) {
await trackerController.adapter.addMergeComment(
pr.title,
pr.targetBranch,
pr.url
);
}

message.push(`🟢 Pull Request was merged`);
if (pr.currentLabels.includes(config.labels['manual-merge'])) {
removeLabel(
Expand Down

0 comments on commit 85d2b14

Please sign in to comment.