Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Allow waiting for actual build #209

Open
richtera opened this issue Nov 15, 2024 · 1 comment
Open

feature: Allow waiting for actual build #209

richtera opened this issue Nov 15, 2024 · 1 comment

Comments

@richtera
Copy link

Currently reviews are initiated when the PR is initially opened which is good, but not great. Ideally it should also consider the first build or status checks on the PR before sending requests for the code to be reviewed. I tried various things, but failed. It would be better if the action internally was able to check whether it already sent the review, then it could be inserted into the normal build flow after all status (lint, format, build and so) are successfully completed.
It could then also be configured to re-request reviews if the repo was setup to require new reviews on new pushes.
Or is there a way to do this I was not able to figure out?

@richtera
Copy link
Author

I was playing with something like this which optionally executes the action. This can be inserted after the build/lint/verify steps so that only valid builds cause the notification. A user can also remove the label to cause a new notification later on (similar to draft non-draft switching)

      - name: Get Pull Request Info
        id: pr-info
        if: ${{ github.event.number != null }}
        uses: actions/github-script@v7
        with:
          result-encoding: string
          script: |
            const pr = await github.rest.pulls.get({
              owner: context.repo.owner,
              repo: context.repo.repo,
              pull_number: context.issue.number
            });
            return pr.data.draft && !pr.data.labels.some(label => label.name === 'review-requested') ? "true" : "false";

      - name: Output info
        run: echo "${{ steps.pr-info.outputs }}"
      
      - name: Conditionally Run Auto-Assign
        if: ${{ github.event.number != null && steps.pr-info.outputs == true }}
        uses: kentaro-m/[email protected]
        with:
          configuration-path: '.github/auto_assign.yaml'

      - name: Add 'review-requested' Label
        if: ${{ github.event.number != null && steps.pr-info.outputs == true }}
        uses: actions/github-script@v6
        with:
          script: |
            await github.rest.issues.addLabels({
              owner: context.repo.owner,
              repo: context.repo.repo,
              issue_number: context.issue.number,
              labels: ['review-requested']
            });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant