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