Review label on PR 241 #87
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: PR review label | |
run-name: Review label on PR ${{ github.event.pull_request.number }} | |
on: | |
pull_request_target: | |
types: [labeled] | |
workflow_dispatch: | |
inputs: | |
pr: | |
description: "PR number" | |
required: true | |
env: | |
PR: ${{ github.event.pull_request.number || inputs.pr }} | |
permissions: | |
contents: read | |
issues: write | |
pull-requests: write | |
jobs: | |
check: | |
if: github.event.label.name == 'review' || inputs.pr | |
runs-on: ubuntu-latest | |
outputs: | |
url: ${{ steps.get-url.outputs.url }} | |
pr: ${{ env.PR }} | |
steps: | |
- name: Unlabel | |
if: github.event.pull_request.number | |
run: | | |
gh --repo "$GITHUB_REPOSITORY" pr edit "$PR" --remove-label review | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get URL | |
id: get-url | |
run: | | |
URL=$(gh --repo "$GITHUB_REPOSITORY" pr diff $PR | grep '^+' | ruby -e 'puts $stdin.read.scan(/href="([^"]+)"/)') | |
echo "Found URL: $URL" | |
echo "url=$URL" >> $GITHUB_OUTPUT | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
review: | |
uses: ./.github/workflows/pr-reviewer.yml | |
needs: | |
- check | |
with: | |
pr: ${{ needs.check.outputs.pr }} | |
url: ${{ needs.check.outputs.url }} | |
secrets: inherit |