build: add label-on-comment workflow
This commit is contained in:
parent
3bf08647e0
commit
dd55df603c
|
|
@ -0,0 +1,58 @@
|
|||
# This workflow runs when a comment is made on the ticket
|
||||
# If the comment starts with "label: " it tries to apply
|
||||
# the label indicated in rest of comment.
|
||||
|
||||
name: Add newly created GitHub Request tickets to the tCRIL Engineering project board
|
||||
on:
|
||||
issue_comment:
|
||||
types: [created]
|
||||
jobs:
|
||||
add_label:
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ startsWith(github.event.comment.body, 'label:') }}
|
||||
steps:
|
||||
- name: parse_label
|
||||
env:
|
||||
BODY: ${{ github.event.comment.body }}
|
||||
run: |
|
||||
# parse and put in env
|
||||
LABEL=${BODY:7}
|
||||
echo "Found label: "$LABEL
|
||||
echo 'LABEL='$LABEL >> $GITHUB_ENV
|
||||
|
||||
- name: apply label
|
||||
uses: actions-ecosystem/action-add-labels@v1
|
||||
with:
|
||||
labels: ${{ env.LABEL }}
|
||||
|
||||
- name: Comment on failure
|
||||
if: ${{ failure() }}
|
||||
env:
|
||||
URL: ${{ github.event.issue.comments_url }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
COMMENT="Failed to add label: "$LABEL
|
||||
curl \
|
||||
-X POST \
|
||||
$URL \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: token $GITHUB_TOKEN" \
|
||||
--data '{ "body": $COMMENT }'
|
||||
|
||||
remove_label:
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ startsWith(github.event.comment.body, 'remove label:') }}
|
||||
steps:
|
||||
- name: parse_label
|
||||
env:
|
||||
BODY: ${{ github.event.comment.body }}
|
||||
run: |
|
||||
# parse and put in env
|
||||
LABEL=${BODY:14}
|
||||
echo "Found label: "$LABEL
|
||||
echo 'LABEL='$LABEL >> $GITHUB_ENV
|
||||
|
||||
- name: remove label
|
||||
uses: actions-ecosystem/action-remove-labels@v1
|
||||
with:
|
||||
labels: ${{ env.LABEL }}
|
||||
Loading…
Reference in New Issue