Skip to content

Fix: Multiple labels in the navigation bar #88

Fix: Multiple labels in the navigation bar

Fix: Multiple labels in the navigation bar #88

Workflow file for this run

name: PR Bot
on:
pull_request_target: # unblock read/write repository permission, even when it is triggered from a public fork - https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#permissions
types: [opened, reopened, ready_for_review] # https://docs.github.com/en/webhooks/webhook-events-and-payloads?actionType=ready_for_review#pull_request
jobs:
missing-template:
name: Auto-draft PRs missing template
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write # Needed for the bot to turn the PR into a draft if the template is missing
# https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-stage-of-a-pull-request
steps:
- name: Check if the PR template was deleted
env:
GH_TOKEN: ${{ github.token }}
BASE_URL: ${{ github.server.url }}/${{ github.repository }}/blob/main
PR_NUMBER: ${{ github.event.number }}
run: |
cmd="gh pr -R ${{ github.repository }}"
if ! $cmd view $PR_NUMBER --json 'body' | grep -q "Description"; then
$cmd ready $PR_NUMBER --undo # mark as draft
$cmd edit $PR_NUMBER --add-label 'missing-template'
$cmd review $PR_NUMBER --request-changes --body "Thanks for contributing to the matrix.org website. I have automatically marked your pull request as a draft. Please restore the [PR template]($BASE_URL/.github/pull_request_template.md?plain=1) to your PR description and follow our [contributing guidelines]($BASE_URL/CONTRIBUTING.md), then undraft to let the team know the PR is ready for review."
exit 1
fi
if $cmd view $PR_NUMBER --json 'labels' | grep -q "missing-template"; then
$cmd edit $PR_NUMBER --remove-label 'missing-template'
$cmd review $PR_NUMBER --approve --body "Thank you for applying the PR template. The PR is now ready for review by a human."
fi