Skip to content

Commit 7e8fb48

Browse files
authored
[FX-NULL] Add ability to ignore certain major update packages (#331)
1 parent 2010991 commit 7e8fb48

File tree

5 files changed

+31
-1
lines changed

5 files changed

+31
-1
lines changed

.changeset/tame-comics-agree.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'davinci-github-actions': minor
3+
---
4+
5+
- do not create contribution tickets for major dependency updates that match the pattern

notify-jira-about-contribution/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Notifies JIRA about external contribution
44

55
### Description
66

7-
Notifies JIRA about external contribution. Draft and dependabot PRs are ignored.
7+
Notifies JIRA about external contribution. Draft and dependabot PRs are ignored (unless `should-notify-about-major-dependency-updates` is set).
88

99
### Inputs
1010

@@ -18,6 +18,7 @@ The list of arguments, that are used in GH Action:
1818
| `jira-hook` | string || | JIRA automation hook for contribution |
1919
| `github-token` | string || | Token for authorization |
2020
| `should-notify-about-major-dependency-updates` | string | | | Specifies if action should create Jira issues for major dependency updates (authored by dependabot, minor and patch versions are ignored) |
21+
| `ignore-major-dependency-update-packages` | string | | /@toptal/ | Regular expression for packages that should be ignored when creating Jira issues for major dependency updates |
2122
| `major-dependency-update-jira-label` | string | | ready-for-refinement | Label that is added if contribution is a dependency update |
2223

2324
### Outputs

notify-jira-about-contribution/action.yml

+5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ inputs:
2323
description: Specifies if action should create Jira issues for major dependency updates (authored by dependabot, minor and patch versions are ignored)
2424
type: boolean
2525
default: false
26+
ignore-major-dependency-update-packages:
27+
required: false
28+
description: Regular expression for packages that should be ignored when creating Jira issues for major dependency updates
29+
default: "/@toptal/"
2630
major-dependency-update-jira-label:
2731
required: false
2832
description: Label that is added if contribution is a dependency update
@@ -70,6 +74,7 @@ runs:
7074
IS_DEPENDABOT_PULL_REQUEST: ${{ steps.is-dependabot-pull-request.outputs.result }}
7175
IS_DRAFT: ${{ fromJson(steps.get-pr.outputs.data).draft }}
7276
SHOULD_NOTIFY_ABOUT_MAJOR_DEPENDENCY_UPDATES: ${{ inputs.should-notify-about-major-dependency-updates }}
77+
IGNORE_MAJOR_DEPENDENCY_UPDATE_PACKAGES: ${{ inputs.ignore-major-dependency-update-packages || '/@toptal/' }}
7378
JIRA_ISSUE_ALREADY_EXISTS: ${{ steps.jira-issue-already-exists.outputs.result }}
7479
PR_TITLE: ${{ fromJson(steps.get-pr.outputs.data).title }}
7580
shell: bash

notify-jira-about-contribution/should-create-jira-issue.sh

+9
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ fi
6666

6767
pullRequestTitle=$PR_TITLE
6868

69+
ignoreMajorDependencyUpdatePackages=$IGNORE_MAJOR_DEPENDENCY_UPDATE_PACKAGES
70+
if [[ -n "$IGNORE_MAJOR_DEPENDENCY_UPDATE_PACKAGES" ]]; then
71+
if [[ "$pullRequestTitle" =~ $IGNORE_MAJOR_DEPENDENCY_UPDATE_PACKAGES ]]; then
72+
echo "Although ths is dependency update and notifying about major dependency updates is turned on, the package is ignored"
73+
echo "result=false" >> $GITHUB_OUTPUT
74+
exit
75+
fi
76+
fi
77+
6978
# Extract major versions using grep utility
7079
# For "Bump @cypress/webpack-preprocessor from 5.17.1 to 6.0.1" it returns "5"
7180
currentMajorVersion=$(echo "$pullRequestTitle" | grep --only-matching --extended-regexp 'from [0-9]+(\.[0-9]+)?' | cut -d' ' -f2 | cut -d'.' -f1)

notify-jira-about-contribution/should-create-jira-issue.test.sh

+10
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ function beforeEach {
1313
export IS_TEAM_MEMBER=false
1414
export IS_DEPENDABOT_PULL_REQUEST=false
1515
export SHOULD_NOTIFY_ABOUT_MAJOR_DEPENDENCY_UPDATES=false
16+
export IGNORE_MAJOR_DEPENDENCY_UPDATE_PACKAGES=""
1617
export PR_TITLE="Test value"
1718
}
1819

@@ -67,6 +68,15 @@ export SHOULD_NOTIFY_ABOUT_MAJOR_DEPENDENCY_UPDATES=true
6768
echo "=== Case: major dependabot pull request ($versionBump), dependabot notifications enabled"
6869
test "Is major dependency update" "true"
6970

71+
beforeEach
72+
versionBump="from 4.17.20 to 5.17.21"
73+
export IS_DEPENDABOT_PULL_REQUEST=true
74+
export PR_TITLE="Bump @toptal/davinci-github-actions $versionBump"
75+
export SHOULD_NOTIFY_ABOUT_MAJOR_DEPENDENCY_UPDATES=true
76+
export IGNORE_MAJOR_DEPENDENCY_UPDATE_PACKAGES="@toptal"
77+
echo "=== Case: major dependabot pull request ($versionBump), dependabot notifications enabled, package is ignored"
78+
test "Although ths is dependency update and notifying about major dependency updates is turned on, the package is ignored" "false"
79+
7080
beforeEach
7181
versionBump="from 4.4 to 7363638339"
7282
export IS_DEPENDABOT_PULL_REQUEST=true

0 commit comments

Comments
 (0)