Skip to content

Label when approved #85

Label when approved

Label when approved #85

Workflow file for this run

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

View workflow run for this annotation

GitHub Actions / Label when approved

Invalid workflow file

The workflow is not valid. .github/workflows/approve_label.yml (Line: 11, Col: 24): Unrecognized named-value: 'env'. Located at position 1 within expression: env.ACCESS_TOKEN_MASTER
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],
});
}