-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: "PR Tags Parsing" | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
- edited | ||
|
||
jobs: | ||
update-pr-tags-comment: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Parse Tags from PR Body | ||
id: parse-tags | ||
run: | | ||
TAGS=$(bash scripts/pr-tags-parse.sh "${{ github.event_path }}") | ||
echo "Parsed Tags: $TAGS" | ||
echo "tags=$TAGS" >> $GITHUB_ENV | ||
- name: Update PR Comment with Tags | ||
run: | | ||
# Define the comment marker | ||
COMMENT_MARKER="<!-- PR Tags -->" | ||
# Fetch existing comments on the PR | ||
COMMENTS=$(gh api repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments) | ||
# Check if a comment with the marker already exists | ||
COMMENT_ID=$(echo "$COMMENTS" | jq -r ".[] | select(.body | contains(\"$COMMENT_MARKER\")) | .id") | ||
# Build the new comment body | ||
NEW_COMMENT="$COMMENT_MARKER\n**E2E Test Tags:** ${{ env.tags }}" | ||
if [ -n "$COMMENT_ID" ]; then | ||
# Update the existing comment | ||
echo "Updating existing comment (ID: $COMMENT_ID)..." | ||
gh api repos/${{ github.repository }}/issues/comments/$COMMENT_ID \ | ||
-X PATCH \ | ||
-F body="$NEW_COMMENT" | ||
else | ||
# Create a new comment | ||
echo "Creating a new comment..." | ||
gh api repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \ | ||
-F body="$NEW_COMMENT" | ||
fi | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |