Skip to content

Commit

Permalink
Update pr-deploy.sh
Browse files Browse the repository at this point in the history
Signed-off-by: Destiny Saturday  <[email protected]>
  • Loading branch information
ThePrimeJnr authored Aug 2, 2024
1 parent cff6a31 commit 19f95ad
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pr-deploy.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/bin/bash

set -e
echo "REPO_URL!: $REPO_URL"
PR_ID="pr_${REPO_ID}${PR_NUMBER}"
DEPLOY_FOLDER="/srv/pr-deploy"
PID_FILE="/srv/pr-deploy/nohup.json"
Expand All @@ -11,6 +10,8 @@ comment() {
local status_message=$1
local preview_url=$2

echo "Status: $status_message"

local comment_body=$(jq -n --arg body "<strong>Here are the latest updates on your deployment.</strong> Explore the action and ⭐ star our project for more insights! 🔍
<table>
<thead>
Expand All @@ -37,6 +38,7 @@ comment() {
-d "$comment_body" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/issues/${PR_NUMBER}/comments" | jq -r '.id')
echo "comment id: $COMMENT_ID"
jq --arg pr_id "$PR_ID" --arg cid "$COMMENT_ID" '.[$pr_id] = $cid' "$COMMENT_ID_FILE" > "$COMMENT_ID_FILE"
else
# Update the existing comment
Expand All @@ -51,6 +53,7 @@ cleanup() {
PID=$(jq -r --arg key "$PR_ID" '.[$key] // ""' "${PID_FILE}")

if [ -n "$PID" ]; then
echo "PID: $PID"
kill -9 "$PID" || true
jq --arg key "$PR_ID" 'del(.[$key])' "${PID_FILE}" > "${PID_FILE}.tmp" && mv "${PID_FILE}.tmp" "${PID_FILE}"
fi
Expand Down

0 comments on commit 19f95ad

Please sign in to comment.