From c5cbb46743af81626efd4db6454e827c43c4de3e Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Wed, 29 Apr 2026 14:04:04 +0200 Subject: [PATCH] Enhance issue matching and redirect handling in close_issue_in_dev workflow --- .github/workflows/close_issue_in_dev.yaml | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/close_issue_in_dev.yaml b/.github/workflows/close_issue_in_dev.yaml index 688f81f27..d61ca0e0a 100644 --- a/.github/workflows/close_issue_in_dev.yaml +++ b/.github/workflows/close_issue_in_dev.yaml @@ -62,10 +62,10 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | issues=$(gh issue list --repo community-scripts/ProxmoxVED --json number,title --jq '.[] | {number, title}') - + best_match_score=0 best_match_number=0 - + for issue in $(echo "$issues" | jq -r '. | @base64'); do _jq() { echo ${issue} | base64 --decode | jq -r ${1} @@ -113,7 +113,8 @@ jobs: const http = require('http'); const url = require('url'); - function request(fullUrl, opts) { + function request(fullUrl, opts, redirectsLeft) { + if (redirectsLeft === undefined) redirectsLeft = 5; return new Promise(function(resolve, reject) { const u = url.parse(fullUrl); const isHttps = u.protocol === 'https:'; @@ -128,6 +129,19 @@ jobs: if (body) options.headers['Content-Length'] = Buffer.byteLength(body); const lib = isHttps ? https : http; const req = lib.request(options, function(res) { + // Follow redirects (301/302/307/308) + if ([301, 302, 307, 308].indexOf(res.statusCode) !== -1 && res.headers.location && redirectsLeft > 0) { + res.resume(); + const nextUrl = url.resolve(fullUrl, res.headers.location); + // For 301/302, browsers historically downgrade to GET; preserve method for 307/308. + const nextOpts = Object.assign({}, opts); + if (res.statusCode === 301 || res.statusCode === 302) { + nextOpts.method = 'GET'; + delete nextOpts.body; + } + resolve(request(nextUrl, nextOpts, redirectsLeft - 1)); + return; + } let data = ''; res.on('data', function(chunk) { data += chunk; }); res.on('end', function() {