|
| 1 | +# This workflow adds the community approval label ("lgtm") to pull requests. It |
| 2 | +# does *not* indicate maintainer approval. This a way to visually highlight that |
| 3 | +# someone in the world thinks the pull request is ready for further review. This |
| 4 | +# event is triggered by a pull request approval, or simply a comment that |
| 5 | +# contains the text "lgtm". |
| 6 | +# Webhook events: Issue comments, Pull request reviews |
| 7 | +name: Community approval |
| 8 | +on: |
| 9 | + repository_dispatch: |
| 10 | + # From: issue_comment, pull_request_review |
| 11 | + types: [created, edited, submitted] |
| 12 | + |
| 13 | +jobs: |
| 14 | + lgtm-comment: |
| 15 | + # Check the comment. contains() is case-insensitive. |
| 16 | + if: >- |
| 17 | + ${{ github.actor == 'tfdocsbot' && |
| 18 | + contains(github.event.client_payload.comment.body, 'LGTM') }} |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - name: Add label |
| 22 | + env: |
| 23 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 24 | + ISSUE_URL: ${{ github.event.client_payload.comment.issue_url }} |
| 25 | + run: | |
| 26 | + curl -X POST \ |
| 27 | + -H "Accept: application/vnd.github.v3+json" \ |
| 28 | + -H "Authorization: token $GITHUB_TOKEN" \ |
| 29 | + "${ISSUE_URL}/labels" \ |
| 30 | + --data '{"labels":["lgtm"]}' |
| 31 | +
|
| 32 | + review-approval: |
| 33 | + # Check the pull request review. |
| 34 | + if: >- |
| 35 | + ${{ github.actor == 'tfdocsbot' && |
| 36 | + contains(github.event.client_payload.review.state, 'approved') }} |
| 37 | + runs-on: ubuntu-latest |
| 38 | + steps: |
| 39 | + - name: Add label |
| 40 | + env: |
| 41 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 42 | + ISSUE_URL: ${{ github.event.client_payload.pull_request.issue_url }} |
| 43 | + run: | |
| 44 | + curl -X POST \ |
| 45 | + -H "Accept: application/vnd.github.v3+json" \ |
| 46 | + -H "Authorization: token $GITHUB_TOKEN" \ |
| 47 | + "${ISSUE_URL}/labels" \ |
| 48 | + --data '{"labels":["lgtm"]}' |
0 commit comments