Added PR/Issue management actions
This commit is contained in:
@@ -22,7 +22,7 @@ jobs:
|
||||
The title of this pull request does not follow the required format. This PR is currently **blocked from merging**.
|
||||
|
||||
To fix this, please update the title to match the following structure:
|
||||
**`EC-[JIRA_NUMBER]: [TYPE]: [Your Description]`**
|
||||
**`EC-[ISSUE_NUMBER]: [TYPE]: [Your Description]`**
|
||||
|
||||
- **Valid [TYPE] values are:** `FEAT`, `FIX`, `DOCS`, `REFACTOR`, `STYLE`, `PERF`, `TEST`, `CHORE`
|
||||
- **Example:** `EC-42: FEAT: Add new user login endpoint`
|
||||
@@ -40,7 +40,7 @@ jobs:
|
||||
<!-- WIP_VALIDATOR_COMMENT -->
|
||||
run: |
|
||||
WIP_LABEL="status: work-in-progress"
|
||||
INVALID_LABEL="INVALID-TITLE-DO-NOT-MERGE"
|
||||
INVALID_LABEL="status: invalid-title"
|
||||
WIP_REGEX="^WIP:"
|
||||
FORMAT_REGEX="^EC-[0-9]+: (FEAT|FIX|DOCS|REFACTOR|STYLE|PERF|TEST|CHORE): .+$"
|
||||
ISSUES_API_URL="$API_BASE_URL/repos/$REPO/issues/$PR_NUMBER"
|
||||
@@ -67,7 +67,7 @@ jobs:
|
||||
elif [[ "$PR_TITLE" =~ $FORMAT_REGEX ]]; then
|
||||
echo "✅ PR title format is correct and not a WIP."
|
||||
echo "Checking for labels to remove..."
|
||||
|
||||
|
||||
CURRENT_LABELS_JSON=$(curl -s -H "Authorization: token $API_TOKEN" "$ISSUES_API_URL/labels")
|
||||
|
||||
INVALID_LABEL_ID=$(echo "$CURRENT_LABELS_JSON" | jq --arg name "$INVALID_LABEL" '.[] | select(.name == $name) | .id')
|
||||
@@ -81,15 +81,15 @@ jobs:
|
||||
echo "Found and removing '$WIP_LABEL' (ID: $WIP_LABEL_ID)..."
|
||||
curl -s -f -X DELETE -H "Authorization: token $API_TOKEN" "$ISSUES_API_URL/labels/$WIP_LABEL_ID"
|
||||
fi
|
||||
|
||||
|
||||
exit 0
|
||||
|
||||
|
||||
else
|
||||
echo "❌ ERROR: PR title does not match the required format."
|
||||
echo "Adding '$INVALID_LABEL' label..."
|
||||
LABEL_JSON=$(echo "$INVALID_LABEL" | jq -R '{"labels": [.]}')
|
||||
curl -s -f -X POST -H "Authorization: token $API_TOKEN" -H "Content-Type: application/json" -d "$LABEL_JSON" "$ISSUES_API_URL/labels"
|
||||
|
||||
|
||||
# Remove WIP label just in case
|
||||
ENCODED_WIP_LABEL=$(python3 -c "import urllib.parse; print(urllib.parse.quote('$WIP_LABEL'))")
|
||||
curl -s -X DELETE -H "Authorization: token $API_TOKEN" "$ISSUES_API_URL/labels/$ENCODED_WIP_LABEL" || true
|
||||
@@ -102,4 +102,4 @@ jobs:
|
||||
curl -s -f -X POST -H "Authorization: token $API_TOKEN" -H "Content-Type: application/json" -d "$COMMENT_JSON" "$ISSUES_API_URL/comments"
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user