name: Issue labeler # Rule 1.6 backstop: issue-form dropdown selections produce body TEXT under # `### ` headings, not labels. This translates the Priority dropdown into # the `priority: high` label. Complexity is intentionally a body field only, not # a label (Rule 2.1), so it is not mapped here. on: issues: types: [opened, edited] permissions: issues: write jobs: label: name: Apply form labels runs-on: ubuntu-latest steps: - name: Apply priority label from the issue form env: GH_TOKEN: ${{ github.token }} REPO: ${{ github.repository }} NUMBER: ${{ github.event.issue.number }} BODY: ${{ github.event.issue.body }} run: | # Print the first non-empty line after a "### " line. value_under() { printf '%s\n' "$BODY" | awk -v h="### $1" ' $0 == h { found = 1; next } found && NF { print; exit } ' } priority=$(value_under "Priority") if [ "$priority" = "High" ]; then gh issue edit "$NUMBER" --repo "$REPO" --add-label "priority: high" else gh issue edit "$NUMBER" --repo "$REPO" --remove-label "priority: high" || true fi