fix(actions): verify proposer issue closure after PR creation #263

Merged
Archicratia merged 1 commits from hotfix/proposer-close-verify into main 2026-03-16 11:54:27 +00:00

View File

@@ -597,6 +597,97 @@ jobs:
);
'
echo "Creating proposer PR..."
PR_JSON="$(curl -fsS -X POST \
-H "Authorization: token $FORGE_TOKEN" \
-H "Content-Type: application/json" \
"$API_BASE/api/v1/repos/$OWNER/$REPO/pulls" \
--data-binary @/tmp/proposer.pr.json)"
PR_URL="$(node --input-type=module -e 'const pr = JSON.parse(process.argv[1] || "{}"); console.log(pr.html_url || pr.url || "");' "$PR_JSON")"
test -n "$PR_URL" || {
echo "PR URL missing. Raw: $PR_JSON"
exit 1
}
echo "PR created: $PR_URL"
for ISSUE in $TARGET_ISSUES; do
export ISSUE PR_URL
node --input-type=module -e '
import fs from "node:fs";
const issue = process.env.ISSUE || "";
const url = process.env.PR_URL || "";
const msg =
`PR proposer créée pour le ticket #${issue} : ${url}\n\n` +
`Le ticket est clôturé automatiquement ; la discussion peut se poursuivre dans la PR.`;
fs.writeFileSync(
"/tmp/proposer.issue.close.comment.json",
JSON.stringify({ body: msg })
);
'
echo "Commenting issue #$ISSUE ..."
COMMENT_HTTP="$(curl -sS -o /tmp/proposer.comment.out.json -w '%{http_code}' -X POST \
-H "Authorization: token $FORGE_TOKEN" \
-H "Content-Type: application/json" \
"$API_BASE/api/v1/repos/$OWNER/$REPO/issues/$ISSUE/comments" \
--data-binary @/tmp/proposer.issue.close.comment.json || true)"
echo "Issue #$ISSUE comment HTTP=$COMMENT_HTTP"
if [[ ! "$COMMENT_HTTP" =~ ^2 ]]; then
echo "Failed to comment issue #$ISSUE"
cat /tmp/proposer.comment.out.json || true
exit 1
fi
echo "Closing issue #$ISSUE ..."
CLOSE_HTTP="$(curl -sS -o /tmp/proposer.close.out.json -w '%{http_code}' -X PATCH \
-H "Authorization: token $FORGE_TOKEN" \
-H "Content-Type: application/json" \
"$API_BASE/api/v1/repos/$OWNER/$REPO/issues/$ISSUE" \
--data-binary '{"state":"closed"}' || true)"
echo "Issue #$ISSUE close HTTP=$CLOSE_HTTP"
if [[ ! "$CLOSE_HTTP" =~ ^2 ]]; then
echo "Failed to close issue #$ISSUE"
cat /tmp/proposer.close.out.json || true
exit 1
fi
echo "Verifying issue #$ISSUE state ..."
VERIFY_HTTP="$(curl -sS -o /tmp/proposer.verify.out.json -w '%{http_code}' \
-H "Authorization: token $FORGE_TOKEN" \
-H "Accept: application/json" \
"$API_BASE/api/v1/repos/$OWNER/$REPO/issues/$ISSUE" || true)"
echo "Issue #$ISSUE verify HTTP=$VERIFY_HTTP"
if [[ ! "$VERIFY_HTTP" =~ ^2 ]]; then
echo "Failed to re-read issue #$ISSUE after close"
cat /tmp/proposer.verify.out.json || true
exit 1
fi
ISSUE_STATE="$(node --input-type=module -e '
import fs from "node:fs";
const j = JSON.parse(fs.readFileSync("/tmp/proposer.verify.out.json", "utf8"));
console.log(String(j.state || ""));
')"
echo "Issue #$ISSUE state=$ISSUE_STATE"
[[ "$ISSUE_STATE" == "closed" ]] || {
echo "Issue #$ISSUE is not closed after PATCH"
cat /tmp/proposer.verify.out.json || true
exit 1
}
done
echo "PR: $PR_URL"
PR_JSON="$(curl -fsS -X POST \
-H "Authorization: token $FORGE_TOKEN" \
-H "Content-Type: application/json" \