Require all PRs to be labelled before merging.
nateberkopec opened this issue · comments
Nate Berkopec commented
I think this could just be a github workflow that is "green" if the PR has any labels except waiting*
labels., and red if the PR has no labels or only a label starting with waiting*
.
This is necessary because our new changelog-generation system uses the labels on Github PRs to determine what "heading" to put it under in the changelog.
sandstrom commented
You can use danger
to solve this (https://danger.systems/ruby/):
# Dangerfile
#
# More details:
# https://danger.systems/reference.html
# gate some checks on running in Github Actions, since they will fail outside it
if danger.scm_provider == :github
# ensure that labels are used
failure 'Please add labels to this PR' if github.pr_labels.empty?
end
And then a Github Actions workflow like this:
# .github/workflows/linting.yml
name: Linting
on:
# run on every pull request
pull_request:
jobs:
repo-linting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
# Certain Danger functionality require the full Git history.
fetch-depth: '0'
- name: Read from .ruby-version file
run: echo "ruby_version=$(cat .ruby-version)" >> $GITHUB_ENV
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.ruby_version }}
bundler-cache: true
- name: Install dependencies
run: |
gem install danger --version '~> 9.0' --no-document
- name: Run danger linting
env:
DANGER_GITHUB_API_TOKEN: ${{secrets.GITHUB_TOKEN}}
RUNNING_IN_ACTIONS: true
run: danger
Nate Berkopec commented
@sandstrom PR? Let's ship it.
sandstrom commented
@nateberkopec I don't have time now, sorry. But the above should get you (or someone else) 90% of the way.
May have time later, but cannot promise.