Label when approved #85
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: Label when approved | ||
on: | ||
pull_request_review: | ||
types: | ||
- submitted | ||
permissions: | ||
pull-requests: write | ||
env: | ||
ACCESS_TOKEN_MASTER: ${{ env.ACCESS_TOKEN_MASTER }} | ||
Check failure on line 11 in .github/workflows/approve_label.yml GitHub Actions / Label when approvedInvalid workflow file
|
||
jobs: | ||
label-when-approved: | ||
name: "Label when approved" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check if PR is approved | ||
id: check-approval | ||
run: | | ||
isApproved=$(echo "${{ github.event.review.state }}" | awk '{print tolower($0)}') | ||
if [[ $isApproved == "approved" ]]; then | ||
echo "::set-output name=isApproved::true" | ||
else | ||
echo "::set-output name=isApproved::false" | ||
fi | ||
- name: Label PR when approved | ||
if: steps.check-approval.outputs.isApproved == 'true' | ||
uses: actions/github-script@v5 | ||
with: | ||
github-token: ${{ secrets.ACCESS_TOKEN }} | ||
script: | | ||
const prNumber = context.payload.pull_request.number; | ||
const labelToAdd = "🎉STATUS : approved"; | ||
const { data: labels } = await github.issues.listLabelsOnIssue({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: prNumber, | ||
}); | ||
const labelExists = labels.some(label => label.name === labelToAdd); | ||
if (!labelExists) { | ||
await github.issues.addLabels({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: prNumber, | ||
labels: [labelToAdd], | ||
}); | ||
} |