Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Dilum Aluthge <[email protected]>
  • Loading branch information
ericphanson and DilumAluthge authored Jan 29, 2024
1 parent 2f49d9c commit 18ecf40
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/author_approval.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ on:
jobs:
label:
permissions:
# We need `write` permissions on `pull-requests` in order to be able to
# add/remove labels from PRs. As far as we can tell, there is no narrower
# permission that we can use.
pull-requests: write
runs-on: ubuntu-latest
# Run on comments that are:
# Run on comments that are satisfy all of the following:
# 1) on PRs, not issues,
# 2) not from bot users and,
# 2) not from bot users
# 3) include the string "merge approved"
# If so, we will do the work to check that the commenter is the package author,
# and conditionally apply the author-approved label.
Expand All @@ -26,7 +29,7 @@ jobs:
COMMENTER: ${{ github.event.comment.user.login }}
shell: julia --compile=min --optimize=0 --color=yes {0}
run: |
m = match(r"Created by: @([^\s]+)", ENV["PR_BODY"])
m = match(r"Created by: @([A-Za-z0-9]*+)(?:$|\n)", ENV["PR_BODY"])
verified = !isnothing(m) && m[1] == ENV["COMMENTER"]
println("Matched user: ", m === nothing ? nothing : m[1])
println("Commenter: ", ENV["COMMENTER"])
Expand All @@ -38,6 +41,9 @@ jobs:
if: ${{ steps.verify-author.outputs.verified == 'true' }}
env:
PR_NUM: ${{ github.event.issue.number }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# We cannot use `${{ secrets.GITHUB_TOKEN }}` here, because
# if we use `GITHUB_TOKEN` here, then the "label created" event
# will not trigger any further GitHub Actions.
GH_TOKEN: ${{ secrets.TAGBOT_TOKEN }}
GH_REPO: ${{ github.repository }}
run: gh pr edit "$PR_NUM" --add-label "package-author-approved"

0 comments on commit 18ecf40

Please sign in to comment.