Reqvire Impact on PR Comment #15
This file contains hidden or 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
| name: ReqFlow Impact on PR Comment | |
| on: | |
| issue_comment: | |
| types: [created] | |
| jobs: | |
| run-change-impact: | |
| if: | | |
| github.event.issue.pull_request != null && | |
| contains(github.event.comment.body, '/reqflow impact') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pull-requests: write | |
| issues: write | |
| contents: read | |
| steps: | |
| - name: React to trigger comment with | |
| uses: peter-evans/create-or-update-comment@v3 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| comment-id: ${{ github.event.comment.id }} | |
| reactions: '+1' | |
| - name: Checkout PR source branch | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # needed for full commit history | |
| - name: Install Rust toolchain | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| toolchain: stable | |
| override: true | |
| - name: Get Base Branch from PR using gh | |
| id: get_pr_base | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| BASE_BRANCH=$(gh pr view ${{ github.event.issue.number }} --json baseRefName --jq '.baseRefName') | |
| echo "Using base branch: $BASE_BRANCH" | |
| echo "BASE_BRANCH=$BASE_BRANCH" >> $GITHUB_ENV | |
| - name: Compute merge base commit | |
| id: base_commit | |
| run: | | |
| git fetch origin "$BASE_BRANCH" | |
| BASE_COMMIT=$(git merge-base origin/"$BASE_BRANCH" HEAD) | |
| echo "Base commit: $BASE_COMMIT" | |
| echo "BASE_COMMIT=$BASE_COMMIT" >> $GITHUB_ENV | |
| - name: Ensure we’re on the PR branch | |
| run: | | |
| git checkout ${{ github.event.issue.pull_request.head.ref }} | |
| echo "Checked out PR branch: ${{ github.event.issue.pull_request.head.ref }}" | |
| - name: Build reqflowcli from source | |
| run: | | |
| cargo build --release | |
| cp target/release/reqflow ./reqflow | |
| - name: Run ReqFlow Change Impact against PR base | |
| id: run_reqflow | |
| run: | | |
| mkdir output | |
| OUTPUT=$(./reqflow --change-impact --git-commit "$BASE_COMMIT" 2>&1 || echo "⚠️ reqflow failed.") | |
| echo "REQFLOW_OUTPUT<<EOF" >> $GITHUB_ENV | |
| echo "$OUTPUT" >> $GITHUB_ENV | |
| echo "EOF" >> $GITHUB_ENV | |
| - name: Comment on PR with result | |
| uses: peter-evans/create-or-update-comment@v3 | |
| with: | |
| issue-number: ${{ github.event.issue.number }} | |
| body: | | |
| ${{ env.REQFLOW_OUTPUT }} |