-
Notifications
You must be signed in to change notification settings - Fork 31
47 lines (47 loc) · 2.01 KB
/
Handler-Comment-Issues.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
name: workflow of automations dispatch to commands in comments
on:
issue_comment:
types: [created]
env:
ISSUE_URL: ${{ github.event.issue.html_url }}
USER_COMMENT: ${{ github.event.comment.user.login }}
NUMBER: ${{ github.event.issue.number }}
COMMENT: ${{ github.event.comment.body }}
jobs:
issue_commented:
# comments in Issues
name: Issue comment
runs-on: ubuntu-latest
steps:
- name: Generate a token of Github APP
id: generate_token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.APP_ID_ADMIN_GITHUB }}
private_key: ${{ secrets.APP_PRIVATE_KEY_ADMIN_GITHUB }}
- name: Read comments and execute actions
id: RunWorkFlow
env:
CMD_ACCEPT_REVIEW: "/review approved"
CMD_ASIGN_ISSUE: "/assign"
VAR_USERS_REVIEWERS: "${{ vars.VAR_USERS_REVIEWERS_ISSUES }}"
VAR_PROJECT_NAME_TO_WORK: "${{ vars.VAR_PROJECT_NAME_TO_WORK }}"
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
#GITHUB_TOKEN: ${{ secrets.PERSONAL_GITHUB_TOKEN }} #Use to personal tooken
run: |
if [[ ${COMMENT,,} == *"$CMD_ACCEPT_REVIEW"* ]];
then
if [[ ${VAR_USERS_REVIEWERS,,} =~ ${USER_COMMENT,,} ]];
then
gh issue edit $ISSUE_URL --remove-label "Review/Pending"
gh issue edit $ISSUE_URL --add-label "Review/Approved"
gh issue edit $ISSUE_URL --add-project "$VAR_PROJECT_NAME_TO_WORK"
gh issue comment $ISSUE_URL --body "The issue was approved and moved to backlog for pending work. If you are interested in working on this problem, you are free to assign it with the /assign comment."
else
gh issue comment $ISSUE_URL --body "The user does not have sufficient permission to approved the issue"
fi
fi
if [[ ${COMMENT,,} == *"$CMD_ASIGN_ISSUE"* ]];
then
gh issue edit $ISSUE_URL --add-assignee "$USER_COMMENT"
fi