MLE-26598 Polaris fix in docker-compose file #3
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: 🏷️ JIRA ID Validator | |
| # Define all valid JIRA project keys for the entire organization here | |
| env: | |
| ORGANIZATION_JIRA_PROJECT_KEYS: "MLE,PDP,COR" | |
| on: | |
| # Required for repository rulesets - works for PRs from forks | |
| pull_request_target: | |
| types: [opened, edited, synchronize, reopened] | |
| # Also support being called as a reusable workflow | |
| workflow_call: | |
| inputs: | |
| pr-title: | |
| required: false | |
| type: string | |
| description: 'The PR title to check (for pull_request_target support)' | |
| regex-pattern: | |
| required: false | |
| type: string | |
| description: 'Custom regex pattern to match JIRA IDs (defaults to "[A-Z]+-[0-9]+")' | |
| default: '[A-Z]+-[0-9]+' | |
| fail-if-no-jira-id: | |
| required: false | |
| type: string | |
| description: 'Whether to fail the check if no JIRA ID is found' | |
| default: 'true' | |
| allow-wip: | |
| required: false | |
| type: string | |
| description: 'Allow PR titles starting with "WIP:" without checking for JIRA ID' | |
| default: 'false' | |
| case-sensitive: | |
| required: false | |
| type: string | |
| description: 'Whether the JIRA project key check should be case-sensitive' | |
| default: 'true' | |
| jobs: | |
| check-jira-id: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: 🏷️ Validate JIRA ticket ID in PR title | |
| shell: bash | |
| run: | | |
| # Get PR title from context or input parameter (for pull_request_target support) | |
| if [[ -n "${{ inputs.pr-title }}" ]]; then | |
| PR_TITLE="${{ inputs.pr-title }}" | |
| echo "Using PR title from input parameter" | |
| else | |
| PR_TITLE="${{ github.event.pull_request.title }}" | |
| echo "Using PR title from GitHub event context" | |
| fi | |
| echo "PR Title: $PR_TITLE" | |
| # Set up inputs as environment variables | |
| # JIRA project keys are defined at the organization level | |
| JIRA_PROJECT_KEYS="${{ env.ORGANIZATION_JIRA_PROJECT_KEYS }}" | |
| REGEX_PATTERN="${{ inputs.regex-pattern }}" | |
| FAIL_IF_NO_JIRA_ID="${{ inputs.fail-if-no-jira-id }}" | |
| ALLOW_WIP="${{ inputs.allow-wip }}" | |
| CASE_SENSITIVE="${{ inputs.case-sensitive }}" | |
| echo "Using organization-wide JIRA project keys: $JIRA_PROJECT_KEYS" | |
| echo "Using regex pattern: $REGEX_PATTERN" | |
| echo "Fail if no JIRA ID: $FAIL_IF_NO_JIRA_ID" | |
| echo "Allow WIP PRs: $ALLOW_WIP" | |
| echo "Case sensitive: $CASE_SENSITIVE" | |
| # Handle WIP PRs | |
| if [[ "$ALLOW_WIP" == "true" && "${PR_TITLE,,}" =~ ^wip: ]]; then | |
| echo "This is a WIP PR. Skipping JIRA ID check." | |
| exit 0 | |
| fi | |
| # Convert comma-separated project keys to array | |
| IFS=',' read -ra PROJECT_KEYS <<< "$JIRA_PROJECT_KEYS" | |
| echo "Valid project keys: ${PROJECT_KEYS[*]}" | |
| # Directly check for valid JIRA IDs in the PR title | |
| VALID_ID_FOUND=false | |
| for VALID_KEY in "${PROJECT_KEYS[@]}"; do | |
| # Create a pattern specifically for this project key | |
| if [[ "$CASE_SENSITIVE" == "true" ]]; then | |
| PATTERN="$VALID_KEY-[0-9]+" | |
| if echo "$PR_TITLE" | grep -q -E "$PATTERN"; then | |
| FOUND_ID=$(echo "$PR_TITLE" | grep -o -E "$PATTERN" | head -1) | |
| echo "Found JIRA ID: $FOUND_ID" | |
| VALID_ID_FOUND=true | |
| break | |
| fi | |
| else | |
| PATTERN="$VALID_KEY-[0-9]+" | |
| if echo "$PR_TITLE" | grep -q -i -E "$PATTERN"; then | |
| FOUND_ID=$(echo "$PR_TITLE" | grep -o -i -E "$PATTERN" | head -1) | |
| echo "Found JIRA ID: $FOUND_ID" | |
| VALID_ID_FOUND=true | |
| break | |
| fi | |
| fi | |
| done | |
| if [[ "$VALID_ID_FOUND" != "true" ]]; then | |
| echo "ERROR: No JIRA ID found in PR title: \"$PR_TITLE\". Valid project keys are: $JIRA_PROJECT_KEYS" | |
| echo "::error::No JIRA ID found in PR title: \"$PR_TITLE\". Valid project keys are: $JIRA_PROJECT_KEYS" | |
| exit 1 | |
| fi |