Skip to content

pull_request_converted_to_draft #1

pull_request_converted_to_draft

pull_request_converted_to_draft #1

Workflow file for this run

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
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.name == 'pull_request_opened' ||
github.event.name == '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: pr-info
with:
repo: ${{ github.event.client_payload.repo }}
number: ${{ github.event.client_payload.number }}
github-token: ${{ secrets.BOT_TOKEN }}
# if build failed, warn that we're going to set 'work in progress' status
- if: |
fromJSON(steps.pr-info.outputs.info).actions.build == 'failure' &&
!contains(toJSON(fromJSON(steps.pr-info.outputs.info).labels), 'status:')
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, set 'work in progress' status label
- if: |
fromJSON(steps.pr-info.outputs.info).pull_request.is_draft == true ||
(fromJSON(steps.pr-info.outputs.info).actions.build == 'failure' &&
!contains(toJSON(fromJSON(steps.pr-info.outputs.info).labels), 'status:'))
uses: roc-streaming/ci/actions/update-labels@main
with:
repo: ${{ github.event.client_payload.repo }}
number: ${{ github.event.client_payload.number }}
add-labels: |
status: work in progress
github-token: ${{ secrets.BOT_TOKEN }}
# if review was requested, or build succeeded and pull request is not draft,
# set 'ready for review' status label
- if: |
fromJSON(steps.pr-info.outputs.info).review.requested == true ||
(fromJSON(steps.pr-info.outputs.info).pull_request.is_draft == false &&
fromJSON(steps.pr-info.outputs.info).actions.build == 'success' &&
!contains(toJSON(fromJSON(steps.pr-info.outputs.info).labels), 'status:'))
uses: roc-streaming/ci/actions/update-labels@main
with:
repo: ${{ github.event.client_payload.repo }}
number: ${{ github.event.client_payload.number }}
add-labels: |
status: 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.name == 'pull_request_review_request_removed' ||
github.event.name == 'pull_request_converted_to_draft') &&
(fromJSON(needs.setup.outputs.pr-info).pull_request.is_draft == true ||
fromJSON(needs.setup.outputs.pr-info).review.requested == false)
runs-on: ubuntu-latest
steps:
# set 'work in progress' status label
- uses: roc-streaming/ci/actions/update-labels@main
with:
repo: ${{ github.event.client_payload.repo }}
number: ${{ github.event.client_payload.number }}
remove-labels: |
status: work in progress
status: needs revision
add-labels: |
status: ready for review
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.name == 'pull_request_review_requested' ||
github.event.name == 'pull_request_ready_for_review') &&
(fromJSON(needs.setup.outputs.pr-info).pull_request.is_draft == false ||
fromJSON(needs.setup.outputs.pr-info).review.requested == true)
runs-on: ubuntu-latest
steps:
# set 'ready for review' status label
- uses: roc-streaming/ci/actions/update-labels@main
with:
repo: ${{ github.event.client_payload.repo }}
number: ${{ github.event.client_payload.number }}
remove-labels: |
status: work in progress
status: needs revision
add-labels: |
status: 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.name == 'pull_request_review_submitted'
runs-on: ubuntu-latest
steps:
# remove all status labels if request is approved
- 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: |
status: ready for review
status: review in progress
status: needs revision
github-token: ${{ secrets.BOT_TOKEN }}
# set 'needs revision' status label if changes requested
- 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: |
status: ready for review
status: work in progress
add-labels: |
status: 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.name == 'pull_request_closed'
runs-on: ubuntu-latest
steps:
# remove all status labels
- uses: roc-streaming/ci/actions/update-labels@main
with:
repo: ${{ github.event.client_payload.repo }}
number: ${{ github.event.client_payload.number }}
remove-labels: |
status: work in progress
status: ready for review
status: review in progress
status: needs revision
status: needs rebase
github-token: ${{ secrets.BOT_TOKEN }}