Configure contributor check for github actions

This commit is contained in:
Brenda Wallace
2020-08-16 20:12:04 +12:00
parent 8eb101138d
commit 42ce0d2b9b
2 changed files with 10 additions and 16 deletions

View File

@@ -1,6 +1,6 @@
name: CI
on: [push, pull_request]
on: [pull_request]
jobs:
contributors:
@@ -8,18 +8,8 @@ jobs:
steps:
- uses: actions/checkout@v1
# Set these so we can run git commands
- run: git config --global user.name "Mona Lisa"
- run: git config --global user.email "email@example.com"
- name: Install ruby version specified in .ruby-version
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Install ruby dependencies
run: |
sudo apt-get -yqq install libpq-dev build-essential libcurl4-openssl-dev
gem install bundler
bundle install --jobs 4 --retry 3
- name: Check contributors
run: |
bundle exec script/check_contributors_md.rb
./script/check_contributors_md.rb

View File

@@ -3,10 +3,12 @@
require "English"
puts "Checking to see if you're in CONTRIBUTORS.md..."
if ENV['CI']
if ENV['GITHUB_EVENT_NAME'] == 'pull_request'
author = ENV['GITHUB_ACTOR']
exit 1 unless author
if ENV['TRAVIS']
if ENV['TRAVIS_PULL_REQUEST']
elsif ENV['TRAVIS_PULL_REQUEST']
require 'httparty'
repo = ENV['TRAVIS_REPO_SLUG']
pr = ENV['TRAVIS_PULL_REQUEST']
@@ -15,7 +17,7 @@ if ENV['TRAVIS']
author = response['user']['login'] if response && response['user']
# Could not determine author
exit unless author
exit 1 unless author
else
# We're in a Travis branch build; nothing to check
exit
@@ -34,6 +36,8 @@ end
# Escape chars in name, and make case insensitive
author_to_search_for = Regexp.new(Regexp.escape(author), Regexp::IGNORECASE)
puts("Checking for #{author} in CONTRIBUTORS.md")
unless File.read('CONTRIBUTORS.md').match?(author_to_search_for)
abort %(
Thanks for your contribution, #{author}!