-
Notifications
You must be signed in to change notification settings - Fork 267
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
1 parent
5821539
commit 7b670aa
Showing
1 changed file
with
45 additions
and
16 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 |
---|---|---|
@@ -1,30 +1,59 @@ | ||
name: PR Comment Trigger | ||
name: Rootstock Integration Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
- '*-rc' | ||
issue_comment: | ||
types: | ||
- created | ||
- edited | ||
pull_request: | ||
types: [opened, reopened, synchronize] | ||
branches: | ||
- "**" | ||
|
||
jobs: | ||
check-pr-comment: | ||
name: Check PR Comment | ||
fetch-pr-info: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Print GitHub Event Information | ||
run: | | ||
echo "GitHub Event Name: ${{ github.event_name }}" | ||
echo "GitHub Event Action: ${{ github.event.action }}" | ||
echo "GitHub Comment Body: ${{ github.event.comment.body }}" | ||
echo "GitHub Repository: ${{ github.repository }}" | ||
echo "GitHub Issue Number: ${{ github.event.issue.number }}" | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Check for /pipeline:run Command | ||
- name: Set up GitHub CLI | ||
uses: cli/cli-action@v2 | ||
|
||
- name: Determine PR Number | ||
id: get_pr_number | ||
run: | | ||
COMMENT_BODY="${{ github.event.comment.body }}" | ||
if [[ "$COMMENT_BODY" == *"/pipeline:run"* ]]; then | ||
echo "Pipeline run command detected in the comment body." | ||
echo "Triggering pipeline..." | ||
# Determine PR number based on the event | ||
if [ -n "${{ github.event.pull_request.number }}" ]; then | ||
PR_NUMBER="${{ github.event.pull_request.number }}" | ||
elif [ -n "${{ github.event.issue.pull_request.url }}" ]; then | ||
PR_URL="${{ github.event.issue.pull_request.url }}" | ||
PR_NUMBER=$(echo "$PR_URL" | awk -F'/' '{print $NF}') | ||
else | ||
echo "Pipeline run command NOT found in the comment body." | ||
echo "No PR number found" | ||
exit 1 | ||
fi | ||
echo "PR_NUMBER=${PR_NUMBER}" >> $GITHUB_ENV | ||
- name: Fetch PR Details | ||
run: | | ||
echo "Fetching details for PR #${{ env.PR_NUMBER }}" | ||
# Fetch PR details using GitHub CLI | ||
gh pr view "${{ env.PR_NUMBER }}" --json title,body,number,comments,reviewRequests --jq ' | ||
.title as $title | | ||
.body as $body | | ||
.number as $number | | ||
.comments.totalCount as $comments | | ||
.reviewRequests.totalCount as $reviewRequests | | ||
"Title: \($title)\nDescription: \($body)\nNumber: \($number)\nComments: \($comments)\nReview Requests: \($reviewRequests)" | ||
' | ||
# Fetch comments | ||
echo "Fetching comments for PR #${{ env.PR_NUMBER }}" | ||
gh pr view "${{ env.PR_NUMBER }}" --comments --jq '.[] | "\(.user.login): \(.body)"' |