name: pr-labels

on:
  push:
    branches:
      - master

jobs:
  is-properly-labeled:
    runs-on: ubuntu-latest

    steps:
      - name: Set up python
        uses: actions/setup-python@v2

      - name: Install requests
        run: pip install requests

      - name: Checkout repository
        uses: actions/checkout@v2

      - name: Process commit and find users responsible for labeling
        id: commit
        run: echo "::set-output name=responsible_users::$(python .github/process_commit.py ${{ github.sha }})"

      - name: Ping users responsible for labeling if necessary
        if: ${{ steps.commit.outputs.responsible_users != '' }}
        uses: mshick/add-pr-comment@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          message: |
            Hey ${{ steps.commit.outputs.responsible_users }}!

            You approved or merged this PR, but no labels were added.
