Skip to content

Commit

Permalink
Creates a New Workflow for Adding Wiki Labels (ParadiseSS13#26066)
Browse files Browse the repository at this point in the history
* Introduces a new workflow for wiki label

* Creates comment on success

* Authorized Users is now a List

* Removes commenting and changes list to repo var

* Changes repo variable name and removes checkout

* Changes to use GitHub ID
  • Loading branch information
Burzah committed Jul 11, 2024
1 parent 55daad4 commit e8a8939
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/wiki_label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: 'PR Wiki Label'
on:
issue_comment:
types: [created]

jobs:
wiki-label:
runs-on: ubuntu-latest
if: github.event.issue.pull_request && github.event.comment.body == '!wiki_label'
permissions:
issues: write
pull-requests: write
steps:
- name: Check commenter authorization
id: check-auth
run: |
IFS=',' read -ra WIKI_MANAGERS <<< "${{ vars.WIKI_MANAGERS }}"
COMMENTER_ID="${{ github.event.comment.user.id }}"
if [[ " ${WIKI_MANAGERS[@]} " =~ " ${COMMENTER_ID} " ]]; then
echo "authorized=true" >> $GITHUB_OUTPUT
else
echo "authorized=false" >> $GITHUB_OUTPUT
fi
- name: Add thumbs up reaction and Wiki label
if: steps.check-auth.outputs.authorized == 'true'
run: |
# Add thumbs up reaction
curl -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions" \
-d '{"content":"+1"}'
# Add label to PR
curl -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/labels" \
-d '["Requires Wiki Update"]'
- name: Unauthorized user thumbs down reaction
if: steps.check-auth.outputs.authorized == 'false'
run: |
curl -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions" \
-d '{"content":"-1"}'

0 comments on commit e8a8939

Please sign in to comment.