Adding initial comment functionality.

This commit is contained in:
2025-11-24 19:33:10 -05:00
parent b1eaed9147
commit eeb26cf0c8
2 changed files with 19 additions and 14 deletions
+6
View File
@@ -42,6 +42,11 @@ inputs:
description: "URL to Apprise API (optional)"
required: false
initial_comment:
description: "Optional comment to post immediately on the newly created issue"
required: false
default: ""
runs:
using: "composite"
steps:
@@ -62,5 +67,6 @@ runs:
POLL_INTERVAL: ${{ inputs.poll_interval }}
REMINDER_INTERVAL: ${{ inputs.reminder_interval }}
APPRISE_API_URL: ${{ inputs.apprise_api_url }}
INITIAL_COMMENT: ${{ inputs.initial_comment }}
run: |
bash "$GITHUB_ACTION_PATH/wait-for-approval.sh"
+13 -14
View File
@@ -1,9 +1,6 @@
#!/usr/bin/env bash
set -euo pipefail
# -----------------------------
# Inputs
# -----------------------------
TOKEN="${TOKEN:?Missing TOKEN}"
API_URL="${API_URL:?Missing API_URL}"
REPO_OWNER="${REPO_OWNER:?Missing REPO_OWNER}"
@@ -13,6 +10,7 @@ APPROVAL_KEYWORDS="${APPROVAL_KEYWORDS:?Missing APPROVAL_KEYWORDS}"
DENIAL_KEYWORDS="${DENIAL_KEYWORDS:?Missing DENIAL_KEYWORDS}"
POLL_INTERVAL="${POLL_INTERVAL:-10}"
REMINDER_INTERVAL="${REMINDER_INTERVAL:-0}"
INITIAL_COMMENT="${INITIAL_COMMENT:-}"
IFS=',' read -r -a approver_list <<< "$APPROVERS"
IFS=',' read -r -a approved_kws <<< "$APPROVAL_KEYWORDS"
@@ -20,32 +18,22 @@ IFS=',' read -r -a denied_kws <<< "$DENIAL_KEYWORDS"
last_reminder=$(date +%s)
# -----------------------------
# Helper: Escape regex special chars
# -----------------------------
escape_regex() {
sed -e 's/[]\/$*.^|[]/\\&/g' <<< "$1"
}
# -----------------------------
# Helper: Notifications
# -----------------------------
notify_func() {
local msg="$1"
echo "::notice::$msg"
# Local notify script
if [[ -x "$GITHUB_ACTION_PATH/notify" ]]; then
bash "$GITHUB_ACTION_PATH/notify" "$msg" || true
fi
# Apprise CLI
if command -v apprise >/dev/null 2>&1; then
apprise -b "$msg" >/dev/null 2>&1 || true
fi
# Apprise API
if [[ -n "${APPRISE_API_URL:-}" ]]; then
curl -s -X POST \
-H "Content-Type: application/json" \
@@ -67,7 +55,6 @@ Reply with:
${APPROVAL_KEYWORDS}
${DENIAL_KEYWORDS}"
# Build assignees JSON
assignees_json=$(jq -nc --arg csv "$APPROVERS" '$csv|split(",")')
json=$(jq -n \
@@ -90,6 +77,18 @@ fi
notify_func "Approval required on issue #$ISSUE"
# -----------------------------
# Step 1b: Post initial comment if provided
# -----------------------------
if [[ -n "$INITIAL_COMMENT" ]]; then
comment_json=$(jq -n --arg body "$INITIAL_COMMENT" '{body:$body}')
curl -s -X POST \
-H "Authorization: token $TOKEN" \
-H "Content-Type: application/json" \
-d "$comment_json" \
"$API_URL/repos/$REPO_OWNER/$REPO_NAME/issues/$ISSUE/comments" >/dev/null
fi
# -----------------------------
# Step 2: Poll for comments
# -----------------------------