mirror of
https://github.com/ChrisTitusTech/linutil.git
synced 2024-11-24 22:14:28 +00:00
ci: Add issue labeling & fix perms (#617)
* Added issue labeling & fixed perms * Added label removing * typo
This commit is contained in:
parent
7641c4e5de
commit
0522697595
58
.github/workflows/issue-slash-commands.yaml
vendored
58
.github/workflows/issue-slash-commands.yaml
vendored
|
@ -1,11 +1,11 @@
|
||||||
name: Close issue on /close
|
name: Issue slash commands
|
||||||
|
|
||||||
on:
|
on:
|
||||||
issue_comment:
|
issue_comment:
|
||||||
types: [created, edited]
|
types: [created, edited]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
closeIssueOnClose:
|
issueCommands:
|
||||||
# Skip this job if the comment was created/edited on a PR
|
# Skip this job if the comment was created/edited on a PR
|
||||||
if: ${{ !github.event.issue.pull_request }}
|
if: ${{ !github.event.issue.pull_request }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
@ -17,6 +17,30 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- run: echo "command=false" >> $GITHUB_ENV
|
- run: echo "command=false" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Check for /label command
|
||||||
|
id: check_label_command
|
||||||
|
run: |
|
||||||
|
if [[ "${{ contains(github.event.comment.body, '/label') }}" == "true" ]]; then
|
||||||
|
echo "command=true" >> $GITHUB_ENV
|
||||||
|
LABEL_NAME=$(echo "${{ github.event.comment.body }}" | awk -F"/label" '/\/label/ { match($2, /'\''([^'\'']*)'\''/, arr); if (arr[1] != "") print arr[1] }')
|
||||||
|
echo "label_command=true" >> $GITHUB_ENV
|
||||||
|
echo "label_name=${LABEL_NAME}" >> $GITHUB_ENV
|
||||||
|
else
|
||||||
|
echo "label_command=false" >> $GITHUB_ENV
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Check for /unlabel command
|
||||||
|
id: check_unlabel_command
|
||||||
|
run: |
|
||||||
|
if [[ "${{ contains(github.event.comment.body, '/unlabel') }}" == "true" ]]; then
|
||||||
|
echo "command=true" >> $GITHUB_ENV
|
||||||
|
UNLABEL_NAME=$(echo "${{ github.event.comment.body }}" | awk -F"/unlabel" '/\/unlabel/ { match($2, /'\''([^'\'']*)'\''/, arr); if (arr[1] != "") print arr[1] }')
|
||||||
|
echo "unlabel_command=true" >> $GITHUB_ENV
|
||||||
|
echo "unlabel_name=${UNLABEL_NAME}" >> $GITHUB_ENV
|
||||||
|
else
|
||||||
|
echo "unlabel_command=false" >> $GITHUB_ENV
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Check for /close command
|
- name: Check for /close command
|
||||||
id: check_close_command
|
id: check_close_command
|
||||||
run: |
|
run: |
|
||||||
|
@ -43,15 +67,15 @@ jobs:
|
||||||
id: check_user
|
id: check_user
|
||||||
if: env.command == 'true'
|
if: env.command == 'true'
|
||||||
run: |
|
run: |
|
||||||
ALLOWED_USERS=("ChrisTitusTech" "afonsofrancof" "Marterich" "MyDrift-user" "Real-MullaC" "nnyyxxxx" "adamperkowski" "lj3954" "jeevithakannan2")
|
ALLOWED_USERS=("ChrisTitusTech" "afonsofrancof" "Marterich" "MyDrift-user" "Real-MullaC" "nnyyxxxx" "adamperkowski" "lj3954" "jeevithakannan2" "${{ github.event.issue.user.login }}")
|
||||||
if [[ " ${ALLOWED_USERS[@]} " =~ " ${{ github.event.comment.user.login }} " ]]; then
|
if [[ " ${ALLOWED_USERS[@]} " =~ " ${{ github.event.comment.user.login }} " ]]; then
|
||||||
echo "user=true" >> $GITHUB_ENV
|
echo "user=true" >> $GITHUB_ENV
|
||||||
else
|
else
|
||||||
echo "user=false" >> $GITHUB_ENV
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Close issue if conditions are met
|
- name: Close issue
|
||||||
if: env.close_command == 'true' && env.user == 'true'
|
if: env.close_command == 'true'
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
ISSUE_NUMBER: ${{ github.event.issue.number }}
|
ISSUE_NUMBER: ${{ github.event.issue.number }}
|
||||||
|
@ -63,11 +87,29 @@ jobs:
|
||||||
gh issue close $ISSUE_NUMBER --repo ${{ github.repository }}
|
gh issue close $ISSUE_NUMBER --repo ${{ github.repository }}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Reopen issue if conditions are met
|
- name: Reopen issue
|
||||||
if: env.reopen_command == 'true' && env.user == 'true'
|
if: env.reopen_command == 'true'
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
ISSUE_NUMBER: ${{ github.event.issue.number }}
|
ISSUE_NUMBER: ${{ github.event.issue.number }}
|
||||||
run: |
|
run: |
|
||||||
echo Reopening the issue...
|
echo Reopening the issue...
|
||||||
gh issue reopen $ISSUE_NUMBER --repo ${{ github.repository }}
|
gh issue reopen $ISSUE_NUMBER --repo ${{ github.repository }}
|
||||||
|
|
||||||
|
- name: Label issue
|
||||||
|
if: env.label_command == 'true'
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
ISSUE_NUMBER: ${{ github.event.issue.number }}
|
||||||
|
run: |
|
||||||
|
echo Labeling the issue...
|
||||||
|
gh issue edit $ISSUE_NUMBER --repo ${{ github.repository }} --add-label "${{ env.label_name }}"
|
||||||
|
|
||||||
|
- name: Remove labels
|
||||||
|
if: env.unlabel_command == 'true'
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
ISSUE_NUMBER: ${{ github.event.issue.number }}
|
||||||
|
run: |
|
||||||
|
echo Unlabeling the issue...
|
||||||
|
gh issue edit $ISSUE_NUMBER --repo ${{ github.repository }} --remove-label "${{ env.unlabel_name }}"
|
Loading…
Reference in New Issue
Block a user