fix(ci): resolve merge conflict and sanitize reviews JSON
Merge dev workflow fix (remove container/install step) and add python3 JSON roundtrip to handle Gitea API responses with control characters that break jq parsing. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -15,20 +15,15 @@ jobs:
|
|||||||
promotion-gate:
|
promotion-gate:
|
||||||
name: Promotion Gate
|
name: Promotion Gate
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: ubuntu:latest
|
|
||||||
timeout-minutes: 5
|
timeout-minutes: 5
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Install dependencies
|
|
||||||
run: apt-get update -qq && apt-get install -y --no-install-recommends ca-certificates curl jq
|
|
||||||
|
|
||||||
- name: Check promotion approval
|
- name: Check promotion approval
|
||||||
env:
|
env:
|
||||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||||
REPO: ${{ github.repository }}
|
REPO: ${{ github.repository }}
|
||||||
BASE_REF: ${{ github.base_ref }}
|
BASE_REF: ${{ github.base_ref }}
|
||||||
HEAD_REF: ${{ github.head_ref }}
|
|
||||||
run: |
|
run: |
|
||||||
if [ -z "${PR_NUMBER}" ] || [ "${PR_NUMBER}" = "null" ]; then
|
if [ -z "${PR_NUMBER}" ] || [ "${PR_NUMBER}" = "null" ]; then
|
||||||
echo "::notice::No PR number in context. Skipping promotion gate."
|
echo "::notice::No PR number in context. Skipping promotion gate."
|
||||||
@@ -60,7 +55,10 @@ jobs:
|
|||||||
GATE_NAME="QA"
|
GATE_NAME="QA"
|
||||||
# For plugin repos (Pipeline A), UAT approval is needed for uat→main
|
# For plugin repos (Pipeline A), UAT approval is needed for uat→main
|
||||||
# Check if the source branch is uat
|
# Check if the source branch is uat
|
||||||
SOURCE_REF="${HEAD_REF}"
|
SOURCE_REF=$(curl -sf \
|
||||||
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
-H "Accept: application/json" \
|
||||||
|
"https://git.farh.net/api/v1/repos/${REPO}/pulls/${PR_NUMBER}" | jq -r '.head.ref')
|
||||||
|
|
||||||
if [ "${SOURCE_REF}" = "uat" ]; then
|
if [ "${SOURCE_REF}" = "uat" ]; then
|
||||||
REQUIRED_REVIEWER="pe_patty"
|
REQUIRED_REVIEWER="pe_patty"
|
||||||
@@ -85,7 +83,8 @@ jobs:
|
|||||||
REVIEWS=$(curl -sf \
|
REVIEWS=$(curl -sf \
|
||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
-H "Accept: application/json" \
|
-H "Accept: application/json" \
|
||||||
"https://git.farh.net/api/v1/repos/${REPO}/pulls/${PR_NUMBER}/reviews")
|
"https://git.farh.net/api/v1/repos/${REPO}/pulls/${PR_NUMBER}/reviews" \
|
||||||
|
| python3 -c 'import sys,json; json.dump(json.load(sys.stdin),sys.stdout)')
|
||||||
|
|
||||||
if [ -z "${REVIEWS}" ] || [ "${REVIEWS}" = "null" ]; then
|
if [ -z "${REVIEWS}" ] || [ "${REVIEWS}" = "null" ]; then
|
||||||
echo "::warning::Could not fetch reviews for PR #${PR_NUMBER}."
|
echo "::warning::Could not fetch reviews for PR #${PR_NUMBER}."
|
||||||
@@ -111,4 +110,4 @@ jobs:
|
|||||||
else
|
else
|
||||||
echo "Promotion gate failed: waiting for ${GATE_NAME} approval from ${REQUIRED_REVIEWER}."
|
echo "Promotion gate failed: waiting for ${GATE_NAME} approval from ${REQUIRED_REVIEWER}."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
Reference in New Issue
Block a user