Skip to content

Commit

Permalink
[PLAY-1580-1] Semver Targets Trigger Correct RCs - Label Check Action (
Browse files Browse the repository at this point in the history
…#3818)

**What does this PR do?** A clear and concise description with your
runway ticket url.
[PLAY-1580](https://runway.powerhrg.com/backlog_items/PLAY-1580)

Adding a Github action that checks for Semver target labels on the Pull
Requests. This action will run whenever a label is added to the PR to
ensure that a target label is present.
  • Loading branch information
skduncan authored Oct 17, 2024
1 parent e64b8dc commit 750c267
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
28 changes: 28 additions & 0 deletions .github/workflows/github-actions-check-labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Check Labels
run-name: ${{ github.actor }} is checking labels 🚀
on:
pull_request:
types: [ labeled, unlabeled ]
jobs:
Checking-Labels:
runs-on: ubuntu-latest
steps:
- name: Check for Semver label
run: |
LABELS=$(jq -r '.pull_request.labels[].name' "$GITHUB_EVENT_PATH")
SEMVER_PATTERN="^(major|minor|patch)$"
SEMVER_LABELS=$(echo "$LABELS" | grep -iE "$SEMVER_PATTERN" || true)
SEMVER_LABEL_COUNT=$(echo "$SEMVER_LABELS" | wc -l)
if [ "$SEMVER_LABEL_COUNT" -eq 0 ]; then
echo "Error: No Semver label found. Please add exactly one of: major, minor, patch (case-insensitive)"
exit 1
elif [ "$SEMVER_LABEL_COUNT" -gt 1 ]; then
echo "Error: Multiple Semver labels found. Please ensure only one is present:"
echo "$SEMVER_LABELS"
exit 1
else
NORMALIZED_LABEL=$(echo "$SEMVER_LABELS" | tr '[:upper:]' '[:lower:]')
echo "Valid Semver label found: $NORMALIZED_LABEL"
fi
2 changes: 1 addition & 1 deletion .github/workflows/github-actions-release-candidate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,4 @@ jobs:
});
} else {
console.log('No pull request found for this commit');
}
}

0 comments on commit 750c267

Please sign in to comment.