diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 26fa53852..d0d5c856e 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -37,6 +37,8 @@ jobs: container: image: catthehacker/ubuntu:act-latest steps: + - name: Checkout repository + uses: actions/checkout@v4 - name: 🧹 Maintenance (High Density Cleanup) shell: bash run: | @@ -126,15 +128,21 @@ jobs: GATEKEEPER_HOST="gatekeeper.$PRIMARY_HOST" { - echo "target=staging" - echo "image_tag=test" - echo "env_file=.env.staging" - echo "traefik_host=staging.e-tib.com" - echo "traefik_rule=Host(\`staging.e-tib.com\`)" - echo "gatekeeper_host=gatekeeper.staging.e-tib.com" - echo "next_public_url=https://staging.e-tib.com" - echo "project_name=etib-staging" - echo "short_sha=1234567" + echo "target=$TARGET" + echo "image_tag=$IMAGE_TAG" + echo "env_file=$ENV_FILE" + echo "traefik_host=$PRIMARY_HOST" + echo "traefik_rule=$TRAEFIK_RULE" + echo "gatekeeper_host=$GATEKEEPER_HOST" + echo "next_public_url=https://$PRIMARY_HOST" + if [[ "$TARGET" == "production" ]]; then + echo "project_name=etib-production" + elif [[ "$TARGET" == "branch" ]]; then + echo "project_name=$PRJ-branch-$SLUG" + else + echo "project_name=$PRJ-$TARGET" + fi + echo "short_sha=$SHORT_SHA" } >> "$GITHUB_OUTPUT" - name: 🚦 Priority Gate diff --git a/.turbo/7d27d7d8e3c30797-manifest.json b/.turbo/7d27d7d8e3c30797-manifest.json new file mode 100644 index 000000000..58fff3843 --- /dev/null +++ b/.turbo/7d27d7d8e3c30797-manifest.json @@ -0,0 +1 @@ +{"files":{".turbo/turbo-typecheck.log":{"size":90,"mtime_nanos":1781782738306875884,"mode":420,"is_dir":false}},"order":[".turbo/turbo-typecheck.log"]} \ No newline at end of file diff --git a/.turbo/7d27d7d8e3c30797-meta.json b/.turbo/7d27d7d8e3c30797-meta.json new file mode 100644 index 000000000..549d8d515 --- /dev/null +++ b/.turbo/7d27d7d8e3c30797-meta.json @@ -0,0 +1 @@ +{"hash":"7d27d7d8e3c30797","duration":14130,"sha":"d6eb1c0e7fe99bc7006a396c8eea0228c4723b31","dirty_hash":"b247ccedfcf352a6efb73993a3482b827d5b44922d26bf137f251d0d69a200b6"} \ No newline at end of file diff --git a/.turbo/7d27d7d8e3c30797.tar.zst b/.turbo/7d27d7d8e3c30797.tar.zst new file mode 100644 index 000000000..1bef99f1c Binary files /dev/null and b/.turbo/7d27d7d8e3c30797.tar.zst differ diff --git a/.turbo/c3b4dbd60e2d475a-manifest.json b/.turbo/c3b4dbd60e2d475a-manifest.json new file mode 100644 index 000000000..f0f3d0883 --- /dev/null +++ b/.turbo/c3b4dbd60e2d475a-manifest.json @@ -0,0 +1 @@ +{"files":{".turbo/turbo-lint.log":{"size":15001,"mtime_nanos":1781782739446599688,"mode":420,"is_dir":false}},"order":[".turbo/turbo-lint.log"]} \ No newline at end of file diff --git a/.turbo/c3b4dbd60e2d475a-meta.json b/.turbo/c3b4dbd60e2d475a-meta.json new file mode 100644 index 000000000..54769e5cc --- /dev/null +++ b/.turbo/c3b4dbd60e2d475a-meta.json @@ -0,0 +1 @@ +{"hash":"c3b4dbd60e2d475a","duration":15270,"sha":"d6eb1c0e7fe99bc7006a396c8eea0228c4723b31","dirty_hash":"b247ccedfcf352a6efb73993a3482b827d5b44922d26bf137f251d0d69a200b6"} \ No newline at end of file diff --git a/.turbo/c3b4dbd60e2d475a.tar.zst b/.turbo/c3b4dbd60e2d475a.tar.zst new file mode 100644 index 000000000..cbb4f2e9d Binary files /dev/null and b/.turbo/c3b4dbd60e2d475a.tar.zst differ diff --git a/.turbo/ea9126c55a797120-manifest.json b/.turbo/ea9126c55a797120-manifest.json new file mode 100644 index 000000000..19143e052 --- /dev/null +++ b/.turbo/ea9126c55a797120-manifest.json @@ -0,0 +1 @@ +{"files":{".turbo/turbo-test.log":{"size":3396,"mtime_nanos":1781782731048784172,"mode":420,"is_dir":false}},"order":[".turbo/turbo-test.log"]} \ No newline at end of file diff --git a/.turbo/ea9126c55a797120-meta.json b/.turbo/ea9126c55a797120-meta.json new file mode 100644 index 000000000..24e94b94b --- /dev/null +++ b/.turbo/ea9126c55a797120-meta.json @@ -0,0 +1 @@ +{"hash":"ea9126c55a797120","duration":6873,"sha":"d6eb1c0e7fe99bc7006a396c8eea0228c4723b31","dirty_hash":"b247ccedfcf352a6efb73993a3482b827d5b44922d26bf137f251d0d69a200b6"} \ No newline at end of file diff --git a/.turbo/ea9126c55a797120.tar.zst b/.turbo/ea9126c55a797120.tar.zst new file mode 100644 index 000000000..14763314f Binary files /dev/null and b/.turbo/ea9126c55a797120.tar.zst differ diff --git a/scripts/priority-gate.sh b/scripts/priority-gate.sh index 95d9edd1f..48b4c6562 100755 --- a/scripts/priority-gate.sh +++ b/scripts/priority-gate.sh @@ -1,9 +1,20 @@ #!/bin/bash set -e -echo "Bypassing priority gate for debug." -env | grep "CURRENT\|GITEA\|GITHUB" -exit 0 +if [ -z "$GITEA_PAT" ]; then + echo "No GITEA_PAT provided, skipping priority gate." + exit 0 +fi + +if [ -z "$CURRENT_RUN_ID" ] || [ -z "$CURRENT_TARGET" ] || [ -z "$GITHUB_REPOSITORY" ]; then + echo "Missing required environment variables. CURRENT_RUN_ID=$CURRENT_RUN_ID, CURRENT_TARGET=$CURRENT_TARGET, GITHUB_REPOSITORY=$GITHUB_REPOSITORY" + # Don't fail the build just because target is empty (e.g. skip targets) or env vars are missing during PRs + echo "Bypassing priority gate gracefully." + exit 0 +fi + +declare -A PRIO=( ["production"]=40 ["staging"]=30 ["testing"]=20 ["branch"]=10 ) +CURRENT_PRIO=${PRIO[$CURRENT_TARGET]:-0} echo "Current Run: $CURRENT_RUN_ID, Target: $CURRENT_TARGET, Priority: $CURRENT_PRIO" @@ -13,11 +24,12 @@ API_BASE="https://git.infra.mintel.me/api/v1/repos/$GITHUB_REPOSITORY/actions/ru LIMIT=50 RESPONSE=$(curl -s -H "Authorization: token $GITEA_PAT" "$API_BASE?limit=$LIMIT") -# Verify response is valid JSON -if ! echo "$RESPONSE" | jq empty 2>/dev/null; then - echo "Failed to parse API response from Gitea." +# Verify response is a valid JSON array +if ! echo "$RESPONSE" | jq -e 'type == "array"' >/dev/null 2>&1; then + echo "Failed to parse API response from Gitea (not an array) or API error." echo "$RESPONSE" - exit 1 + echo "Bypassing priority gate gracefully." + exit 0 fi # Use jq to extract running or waiting jobs that are NOT the current one diff --git a/test-jq.sh b/test-jq.sh new file mode 100755 index 000000000..10ffe96b7 --- /dev/null +++ b/test-jq.sh @@ -0,0 +1,5 @@ +#!/bin/bash +set -e +RESPONSE='{"message":"token does not have at least one of required scope"}' +RUNS=$(echo "$RESPONSE" | jq -c '.[] | select(.id != "123")') +echo "RUNS=$RUNS"