pull_request_labeled #295
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: "auto_status" | |
| on: | |
| repository_dispatch: | |
| types: | |
| # on-open | |
| - pull_request_opened | |
| - pull_request_reopened | |
| # on-wip | |
| - pull_request_review_request_removed | |
| - pull_request_converted_to_draft | |
| # on-ready | |
| - pull_request_review_requested | |
| - pull_request_ready_for_review | |
| # on-review | |
| - pull_request_review_submitted | |
| # on-close | |
| - pull_request_closed | |
| # on-label | |
| - pull_request_labeled | |
| concurrency: | |
| group: ${{ github.event.client_payload.repo }}/${{ github.workflow }} | |
| jobs: | |
| setup: | |
| outputs: | |
| automation-config: ${{ steps.automation-config.outputs.config }} | |
| pr-info: ${{ steps.pr-info.outputs.info }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: roc-streaming/ci/actions/automation-config@main | |
| id: automation-config | |
| with: | |
| repo: ${{ github.event.client_payload.repo }} | |
| github-token: ${{ secrets.BOT_TOKEN }} | |
| - uses: roc-streaming/ci/actions/pullreq-info@main | |
| id: pr-info | |
| with: | |
| repo: ${{ github.event.client_payload.repo }} | |
| number: ${{ github.event.client_payload.number }} | |
| github-token: ${{ secrets.BOT_TOKEN }} | |
| # pull request opened | |
| on-open: | |
| needs: setup | |
| if: | | |
| fromJSON(needs.setup.outputs.automation-config).auto_status != null && | |
| (github.event.action == 'pull_request_opened' || | |
| github.event.action == 'pull_request_reopened') | |
| runs-on: ubuntu-latest | |
| steps: | |
| # wait until build workflow completes | |
| - uses: roc-streaming/ci/actions/wait-checks@main | |
| with: | |
| workflow: ${{ fromJSON(needs.setup.outputs.automation-config).auto_status.wait_workflow }} | |
| repo: ${{ github.event.client_payload.repo }} | |
| number: ${{ github.event.client_payload.number }} | |
| github-token: ${{ secrets.BOT_TOKEN }} | |
| # get pull request info with up-to-date build status | |
| - uses: roc-streaming/ci/actions/pullreq-info@main | |
| id: new-pr-info | |
| with: | |
| repo: ${{ github.event.client_payload.repo }} | |
| number: ${{ github.event.client_payload.number }} | |
| github-token: ${{ secrets.BOT_TOKEN }} | |
| # if build failed, post comment that we're going to add 'work-in-progress' status | |
| - if: | | |
| fromJSON(steps.new-pr-info.outputs.info).actions.build == 'failure' && | |
| !contains(toJSON(fromJSON(steps.new-pr-info.outputs.info).labels), 'S-') | |
| uses: roc-streaming/ci/actions/post-comment@main | |
| with: | |
| repo: ${{ github.event.client_payload.repo }} | |
| number: ${{ github.event.client_payload.number }} | |
| text: ":robot: Pull request has failed checks and was automatically marked as | |
| work-in-progress. | |
| \n | |
| If you believe the failures are unrelated or you want an early review, click on | |
| the `request review` button. Otherwise, please fix failures before requesting review." | |
| github-token: ${{ secrets.BOT_TOKEN }} | |
| # if pull request is draft, or build failed, add 'work-in-progress' status | |
| - if: | | |
| fromJSON(steps.new-pr-info.outputs.info).pull_request.is_draft == true || | |
| (fromJSON(steps.new-pr-info.outputs.info).actions.build == 'failure' && | |
| !contains(toJSON(fromJSON(steps.new-pr-info.outputs.info).labels), 'S-')) | |
| uses: roc-streaming/ci/actions/update-labels@main | |
| with: | |
| repo: ${{ github.event.client_payload.repo }} | |
| number: ${{ github.event.client_payload.number }} | |
| add-labels: | | |
| S-work-in-progress | |
| github-token: ${{ secrets.BOT_TOKEN }} | |
| # if review was requested, or build succeeded and pull request is not draft, | |
| # add 'ready-for-review' status | |
| - if: | | |
| fromJSON(steps.new-pr-info.outputs.info).review.requested == true || | |
| (fromJSON(steps.new-pr-info.outputs.info).pull_request.is_draft == false && | |
| fromJSON(steps.new-pr-info.outputs.info).actions.build == 'success' && | |
| !contains(toJSON(fromJSON(steps.new-pr-info.outputs.info).labels), 'S-')) | |
| uses: roc-streaming/ci/actions/update-labels@main | |
| with: | |
| repo: ${{ github.event.client_payload.repo }} | |
| number: ${{ github.event.client_payload.number }} | |
| add-labels: | | |
| S-ready-for-review | |
| github-token: ${{ secrets.BOT_TOKEN }} | |
| # pull request drafted or review request removed | |
| on-wip: | |
| needs: setup | |
| if: | | |
| fromJSON(needs.setup.outputs.automation-config).auto_status != null && | |
| ((github.event.action == 'pull_request_review_request_removed' && | |
| fromJSON(needs.setup.outputs.pr-info).review.requested == false) || | |
| (github.event.action == 'pull_request_converted_to_draft' && | |
| fromJSON(needs.setup.outputs.pr-info).pull_request.is_draft == true)) | |
| runs-on: ubuntu-latest | |
| steps: | |
| # switch to 'work-in-progress' status | |
| - uses: roc-streaming/ci/actions/update-labels@main | |
| with: | |
| repo: ${{ github.event.client_payload.repo }} | |
| number: ${{ github.event.client_payload.number }} | |
| remove-labels: | | |
| S-ready-for-review | |
| S-needs-revision | |
| add-labels: | | |
| S-work-in-progress | |
| github-token: ${{ secrets.BOT_TOKEN }} | |
| # pull request undrafted or review requested | |
| on-ready: | |
| needs: setup | |
| if: | | |
| fromJSON(needs.setup.outputs.automation-config).auto_status != null && | |
| ((github.event.action == 'pull_request_review_requested' && | |
| fromJSON(needs.setup.outputs.pr-info).review.requested == true) || | |
| (github.event.action == 'pull_request_ready_for_review' && | |
| fromJSON(needs.setup.outputs.pr-info).pull_request.is_draft == false)) | |
| runs-on: ubuntu-latest | |
| steps: | |
| # switch to 'ready-for-review' status | |
| - uses: roc-streaming/ci/actions/update-labels@main | |
| with: | |
| repo: ${{ github.event.client_payload.repo }} | |
| number: ${{ github.event.client_payload.number }} | |
| remove-labels: | | |
| S-work-in-progress | |
| S-needs-revision | |
| add-labels: | | |
| S-ready-for-review | |
| github-token: ${{ secrets.BOT_TOKEN }} | |
| # pull request reviewed | |
| on-review: | |
| needs: setup | |
| if: | | |
| fromJSON(needs.setup.outputs.automation-config).auto_status != null && | |
| github.event.action == 'pull_request_review_submitted' | |
| runs-on: ubuntu-latest | |
| steps: | |
| # if review descision is approved, clear status | |
| - if: | | |
| fromJSON(needs.setup.outputs.pr-info).review.decision == 'approved' | |
| uses: roc-streaming/ci/actions/update-labels@main | |
| with: | |
| repo: ${{ github.event.client_payload.repo }} | |
| number: ${{ github.event.client_payload.number }} | |
| remove-labels: | | |
| S-work-in-progress | |
| S-ready-for-review | |
| S-review-in-progress | |
| S-needs-revision | |
| github-token: ${{ secrets.BOT_TOKEN }} | |
| # if review decision is request changes, switch to 'needs-revision' status | |
| - if: | | |
| fromJSON(needs.setup.outputs.pr-info).review.decision == 'changes_requested' | |
| uses: roc-streaming/ci/actions/update-labels@main | |
| with: | |
| repo: ${{ github.event.client_payload.repo }} | |
| number: ${{ github.event.client_payload.number }} | |
| remove-labels: | | |
| S-work-in-progress | |
| S-ready-for-review | |
| S-review-in-progress | |
| add-labels: | | |
| S-needs-revision | |
| github-token: ${{ secrets.BOT_TOKEN }} | |
| # pull request closed | |
| on-close: | |
| needs: setup | |
| if: | | |
| fromJSON(needs.setup.outputs.automation-config).auto_status != null && | |
| github.event.action == 'pull_request_closed' | |
| runs-on: ubuntu-latest | |
| steps: | |
| # clear status | |
| - uses: roc-streaming/ci/actions/update-labels@main | |
| with: | |
| repo: ${{ github.event.client_payload.repo }} | |
| number: ${{ github.event.client_payload.number }} | |
| remove-labels: | | |
| S-work-in-progress | |
| S-ready-for-review | |
| S-review-in-progress | |
| S-needs-revision | |
| S-needs-rebase | |
| github-token: ${{ secrets.BOT_TOKEN }} | |
| # if closed request has 'borked' status, also add 'invalid' label | |
| - if: | | |
| contains(fromJSON(needs.setup.outputs.pr-info).labels, 'S-borked') | |
| uses: roc-streaming/ci/actions/update-labels@main | |
| with: | |
| repo: ${{ github.event.client_payload.repo }} | |
| number: ${{ github.event.client_payload.number }} | |
| add-labels: | | |
| invalid | |
| github-token: ${{ secrets.BOT_TOKEN }} | |
| # pull request labeled | |
| on-label: | |
| needs: setup | |
| if: | | |
| fromJSON(needs.setup.outputs.automation-config).auto_status != null && | |
| github.event.action == 'pull_request_labeled' | |
| runs-on: ubuntu-latest | |
| steps: | |
| # when 'borked' status is added, post informational comment | |
| - if: | | |
| github.event.client_payload.label == 'S-borked' | |
| uses: roc-streaming/ci/actions/post-comment@main | |
| with: | |
| repo: ${{ github.event.client_payload.repo }} | |
| number: ${{ github.event.client_payload.number }} | |
| text: | | |
| :robot: **Review blocked** | |
| Hi! Review has been blocked due to one or more significant quality issues: | |
| * fails to compile | |
| * fails to follow coding guidelines | |
| * contains hallucinated or invalid code | |
| To save everyone's time, please validate your changes locally before submitting a patch. | |
| github-token: ${{ secrets.BOT_TOKEN }} |