diff --git a/.github/workflows/rit.yml b/.github/workflows/rit.yml index f91f6def6b7..f68887ec1b6 100644 --- a/.github/workflows/rit.yml +++ b/.github/workflows/rit.yml @@ -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)"'