|
1 | 1 | #!/bin/bash |
2 | 2 |
|
3 | 3 | if [ "$PR_TITLE" == "" ]; then |
4 | | - echo "env variable PR_TITLE is required" |
| 4 | + echo "Error: Missing required environment variable PR_TITLE |
| 5 | +Action: Please set the PR_TITLE environment variable." |
5 | 6 | exit 1 |
6 | 7 | fi |
7 | 8 | if [ "$PR_BRANCH" == "" ]; then |
8 | | - echo "env variable PR_BRANCH is required" |
| 9 | + echo "Error: Missing required environment variable PR_BRANCH |
| 10 | +Action: Please set the PR_BRANCH environment variable." |
9 | 11 | exit 1 |
10 | 12 | fi |
11 | 13 | if [ "$LATEST_RELEASE" == "" ]; then |
12 | | - echo "env variable LATEST_RELEASE is required" |
| 14 | + echo "Error: Missing required environment variable LATEST_RELEASE |
| 15 | +Action: Please set the LATEST_RELEASE environment variable." |
13 | 16 | exit 1 |
14 | 17 | fi |
15 | 18 | if [ "$PACKAGE_VERSION" == "" ]; then |
16 | | - echo "env variable PACKAGE_VERSION is required" |
| 19 | + echo "Error: Missing required environment variable PACKAGE_VERSION |
| 20 | +Action: Please set the PACKAGE_VERSION environment variable." |
17 | 21 | exit 1 |
18 | 22 | fi |
19 | 23 | if [ "$TARGET_BRANCH" == "" ]; then |
20 | | - echo "env variable TARGET_BRANCH is required" |
| 24 | + echo "Error: Missing required environment variable TARGET_BRANCH |
| 25 | +Action: Please set the TARGET_BRANCH environment variable." |
21 | 26 | exit 1 |
22 | 27 | fi |
23 | 28 |
|
@@ -69,31 +74,63 @@ if [[ "$TARGET_BRANCH" == "develop" ]] || [[ "$TARGET_BRANCH" =~ ^release/v ]] | |
69 | 74 | exit 0 |
70 | 75 | fi |
71 | 76 | if [[ ! "$PR_TITLE" =~ $SEMANTIC_PREFIXES ]]; then |
72 | | - echo "PR title must start with a valid semantic prefix (e.g., feat:, fix:)." |
| 77 | + echo "Error: Invalid PR title format |
| 78 | +Details: |
| 79 | +- Current title: $PR_TITLE |
| 80 | +Action: Update the PR title to start with a valid semantic prefix |
| 81 | +Valid prefixes: feat:, fix:, chore:, docs:, style:, refactor:, perf:, test: |
| 82 | +Example: feat: Add new feature (ABC-123)" |
73 | 83 | exit 1 |
74 | 84 | fi |
75 | 85 |
|
76 | 86 | if [[ ! "$PR_TITLE" =~ $JIRA_TICKET ]]; then |
77 | | - echo "PR title must contain a valid Jira ticket ID (e.g., ABC-123)." |
| 87 | + echo "Error: Missing Jira ticket reference in PR title |
| 88 | +Details: |
| 89 | +- Current title: $PR_TITLE |
| 90 | +Action: Include a Jira ticket ID in the PR title using the format (ABC-123) |
| 91 | +Example: feat: Add new feature (ABC-123)" |
78 | 92 | exit 1 |
79 | 93 | fi |
80 | 94 | fi |
81 | 95 |
|
82 | 96 | if [[ "$TARGET_BRANCH" == "main" ]]; then |
83 | 97 | if [[ "$PR_BRANCH" =~ ^release/v ]] || [[ "$PR_BRANCH" =~ ^hotfix/v ]]; then |
84 | 98 | if [[ ! "$PR_BRANCH" =~ ^release/v$PACKAGE_VERSION ]] && [[ ! "$PR_BRANCH" =~ ^hotfix/v$PACKAGE_VERSION ]]; then |
85 | | - echo "PR branch and package version must match" |
| 99 | + echo "Error: Mismatch between the pull request branch and the package version. |
| 100 | +Details: |
| 101 | +- PR Branch: $PR_BRANCH |
| 102 | +- Latest Release: $LATEST_RELEASE |
| 103 | +- Package Version: $PACKAGE_VERSION |
| 104 | +Action: Update the PR branch name or package version to ensure consistency. |
| 105 | +For more details on naming conventions, refer to our workflow documentation. |
| 106 | +See: https://virdocs.atlassian.net/wiki/x/AYAqHAE" |
86 | 107 | exit 1 |
87 | 108 | elif [ "$(compare_versions $PACKAGE_VERSION $LATEST_RELEASE)" != "1" ]; then |
88 | | - echo "Next predicted version must be higher than the latest release." |
| 109 | + echo "Error: Invalid version increment |
| 110 | +Details: |
| 111 | +- Current version: $PACKAGE_VERSION |
| 112 | +- Latest release: $LATEST_RELEASE |
| 113 | +Action: Update the package version to be higher than the latest release |
| 114 | +Example: If latest is 1.0.0, next version should be > 1.0.0 (e.g., 1.0.1, 1.1.0, 2.0.0) |
| 115 | +For version numbering guidelines, see: https://semver.org/" |
89 | 116 | exit 1 |
90 | 117 | fi |
91 | 118 | else |
92 | | - echo "PR branch must be release/v$PACKAGE_VERSION or hotfix/v$PACKAGE_VERSION" |
| 119 | + echo "Error: Invalid branch name for main target |
| 120 | +Details: |
| 121 | +- Current branch: $PR_BRANCH |
| 122 | +- Target branch: main |
| 123 | +Action: Only release or hotfix branches can be merged to main |
| 124 | +Expected format: release/v$PACKAGE_VERSION or hotfix/v$PACKAGE_VERSION" |
93 | 125 | exit 1 |
94 | 126 | fi |
95 | 127 | if [[ ! "$PR_BRANCH" =~ ^release/v$PACKAGE_VERSION ]] && [[ ! "$PR_BRANCH" =~ ^hotfix/v$PACKAGE_VERSION ]]; then |
96 | | - echo "PR branch must be release/v$PACKAGE_VERSION or hotfix/v$PACKAGE_VERSION" |
| 128 | + echo "Error: Branch name does not match package version |
| 129 | +Details: |
| 130 | +- Current branch: $PR_BRANCH |
| 131 | +- Package version: $PACKAGE_VERSION |
| 132 | +Action: Rename branch to match package version |
| 133 | +Expected format: release/v$PACKAGE_VERSION or hotfix/v$PACKAGE_VERSION" |
97 | 134 | exit 1 |
98 | 135 | fi |
99 | 136 | fi |
|
0 commit comments