Skip to content

Commit

Permalink
new pr workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
midleman committed Dec 11, 2024
1 parent 2b20896 commit bef0ebd
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/parse-pr-tags.yml
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 }}

0 comments on commit bef0ebd

Please sign in to comment.