Skip to content

Commit

Permalink
feat(notify): Add allow-out-of-sync option
Browse files Browse the repository at this point in the history
  • Loading branch information
Alorel committed Sep 17, 2023
1 parent ea84f1a commit 3fe812a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ This action lives under `/notify`.
| `labels` | :heavy_check_mark: | `Released` | Labels to apply to released issues (1 per line) |
| `gh-token` | :heavy_check_mark: | `${{ github.token }}` | API token to use |
| `error-on-ratelimit` | :x: | `false` | Error if the GitHub API token gits a rate limit (true) or just warn (false) |
| `error-on-out-of-sync` | :x: | `false` | If we're behind/ahead of the remote, should the action skip notifications, but succeed (false) or fail with an error (true)? |
| `error-on-out-of-sync` | :x: | `false` | If we're behind/ahead of the remote, should the action skip notifications, but succeed (false) or fail with an error (true)? Overridden by `allow-out-of-sync`. |
| `allow-out-of-sync` | :x: | `false` | Continue with notifications even if we're out of sync with the remote. Takes precedence over `error-on-ratelimit`. |
| `comment` | :heavy_check_mark: | `This issue has been included in [{{tag}}]({{releaseUrl}}) :tada:` | The comment that'll be made on every issue. Accepts placeholders in the form of `{{name}}` - list included below. |


Expand Down
6 changes: 5 additions & 1 deletion src/modules/notify/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ inputs:
tag:
description: Tag that just got released
required: true
allow-out-of-sync:
description: Continue with notifications even if we're out of sync with the remote. Takes precedence over `error-on-ratelimit`.
default: 'false'
required: true
issues:
description: List of issue numbers separated by comma to notify
required: true
Expand All @@ -20,7 +24,7 @@ inputs:
required: true
default: ${{ github.token }}
error-on-ratelimit:
description: Error if the GitHub API token gits a rate limit
description: Fail the step if the GitHub API token gits a rate limit instead of just printing a warning.
required: false
default: 'false'
error-on-out-of-sync:
Expand Down
13 changes: 10 additions & 3 deletions src/modules/notify/index.mts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {RatelimitTracker} from './ratelimit-tracker.mjs';
export interface NotifyInputs {
comment: string;

'allow-out-of-sync': boolean;

'error-on-out-of-sync': boolean;

'error-on-ratelimit': boolean;
Expand All @@ -24,6 +26,7 @@ export interface NotifyInputs {
(async function notifyAction(): Promise<any> {
const inputs = new InputMgr<NotifyInputs>({
comment: [String, {required: true}],
'allow-out-of-sync': Boolean,
'error-on-ratelimit': Boolean,
'error-on-out-of-sync': Boolean,
'gh-token': [String, {required: true}],
Expand Down Expand Up @@ -54,9 +57,13 @@ export interface NotifyInputs {
} catch (e) {
const msg = (e as OutOfSyncError).message;

return inputs['error-on-out-of-sync']
? setFailed(msg)
: warning(`${msg} Skipping the step.`);
if (inputs['error-on-out-of-sync']) {
return setFailed(msg);
} else if (inputs['allow-out-of-sync']) {
warning(msg);
} else {
return warning(`${msg} Skipping the step.`);
}
}

const rateLimiter = new RatelimitTracker();
Expand Down

0 comments on commit 3fe812a

Please sign in to comment.