feat: Add GitHub Action as a contributor #2
Workflow file for this run
This file contains 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: First Time Contributor Action | |
on: | |
pull_request: | |
types: [opened] | |
jobs: | |
first_time_contributor: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install jq | |
run: sudo apt-get install -y jq | |
- name: Check if contributor is first-timer | |
id: check | |
run: | | |
IS_FIRST_TIME_CONTRIBUTOR=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/open-sauced/guestbook/pulls?state=closed&author=${{ github.actor }} | jq '. | length') | |
echo "::set-output name=is_first_time_contributor::$IS_FIRST_TIME_CONTRIBUTOR" | |
shell: bash | |
- name: Post comment for first-time contributors | |
if: contains(github.event.pull_request.title, 'as a contributor') | |
run: | | |
PR_COMMENT="Congratulations on completing Chapter 5 of the Intro to OSS Course with your contribution to this repository! You're almost to the end of the course. Create a highlight of your contribution to our guestbook using the instructions in [chapter 6](https://github.com/open-sauced/intro/blob/main/06-the-secret-sauce.md) and share it with us!" | |
curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -X POST -d "{\"body\":\"$PR_COMMENT\"}" "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" |