Skip to content

My Story

My Story #6

Workflow file for this run

name: Approval Tracking
on:
issue_comment:
types: [created]
jobs:
approval:
runs-on: ubuntu-latest
steps:
- name: Check for approval comment
if: contains(github.event.comment.body, '/approve')
run: |
ISSUE_NUMBER=${{ github.event.issue.number }}
APPROVER=${{ github.actor }}
# Add approval label based on the approver
if [[ "$APPROVER" == "product-owner-username" ]]; then
LABEL="Product Owner Approved"
elif [[ "$APPROVER" == "developer-username" ]]; then
LABEL="Developer Approved"
elif [[ "$APPROVER" == "qa-username" ]]; then
LABEL="QA Approved"
fi
# Add the appropriate label
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/labels \
-d '{"labels":["Product Owner Approved"]}'