1616 schedule :
1717 - cron : " 0 0 * * 1"
1818 pull_request :
19+ types : [opened, synchronize, reopened, labeled]
1920 push :
2021 branches :
2122 - master
@@ -391,8 +392,11 @@ jobs:
391392 !dist/*PAYG*.rpm
392393 !dist/*fips*.rpm
393394 resolve-dashboard-image :
394- if : github.event.pull_request.draft == false
395395 needs : goreleaser
396+ if : |
397+ !cancelled() &&
398+ needs.goreleaser.result == 'success' &&
399+ github.event.pull_request.draft == false
396400 runs-on : ${{ vars.DEFAULT_RUNNER }}
397401 permissions :
398402 id-token : write
@@ -407,6 +411,7 @@ jobs:
407411 uses : actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
408412 with :
409413 fetch-depth : 0
414+ persist-credentials : false
410415 ref : ${{ github.event.pull_request.head.sha }}
411416 - name : Check for relevant package changes in PR
412417 id : check_changes
@@ -516,6 +521,7 @@ jobs:
516521 COMMIT_SHA : ${{ github.sha }}
517522 PR_NUMBER : ${{ github.event.pull_request.number }}
518523 HAS_RELEVANT_CHANGES : ${{ steps.check_changes.outputs.has_relevant_changes }}
524+ ORG_GH_TOKEN : ${{ secrets.ORG_GH_TOKEN }}
519525 run : |
520526 echo "=================================="
521527 echo "📊 Dashboard Image Resolution"
@@ -530,14 +536,23 @@ jobs:
530536 echo "Has relevant changes in PR: $HAS_RELEVANT_CHANGES"
531537 echo "=================================="
532538
533- # Only use custom build strategies for PRs targeting master
539+ # For non-master base branches, check if the same branch exists in tyk-analytics
534540 if [ "$BASE_REF" != "master" ]; then
535- echo "ℹ️ Strategy: Use gromit default (base branch is not master)"
536- echo " → Custom builds only for master branch PRs"
537- echo "dashboard_image=" >> $GITHUB_OUTPUT
538- echo "needs_build=false" >> $GITHUB_OUTPUT
539- echo "dashboard_branch=" >> $GITHUB_OUTPUT
540- echo "strategy=gromit-default" >> $GITHUB_OUTPUT
541+ if git ls-remote --exit-code --heads "https://x-access-token:${ORG_GH_TOKEN}@github.com/TykTechnologies/tyk-analytics.git" "refs/heads/$BASE_REF" > /dev/null 2>&1; then
542+ echo "📋 Strategy: Use release branch '$BASE_REF' from tyk-analytics"
543+ echo " → Base branch exists in tyk-analytics, using it directly"
544+ echo "dashboard_image=${REGISTRY}/tyk-analytics:${BASE_REF}" >> $GITHUB_OUTPUT
545+ echo "needs_build=false" >> $GITHUB_OUTPUT
546+ echo "dashboard_branch=$BASE_REF" >> $GITHUB_OUTPUT
547+ echo "strategy=release-branch-match" >> $GITHUB_OUTPUT
548+ else
549+ echo "ℹ️ Strategy: Use gromit default (base branch '$BASE_REF' not found in tyk-analytics)"
550+ echo " → Falling back to gromit default"
551+ echo "dashboard_image=" >> $GITHUB_OUTPUT
552+ echo "needs_build=false" >> $GITHUB_OUTPUT
553+ echo "dashboard_branch=" >> $GITHUB_OUTPUT
554+ echo "strategy=gromit-default" >> $GITHUB_OUTPUT
555+ fi
541556
542557 # Strategy 1: Matching branch exists in tyk-analytics → use gromit
543558 elif [ "$BRANCH_EXISTS" = "true" ]; then
@@ -582,8 +597,11 @@ jobs:
582597 echo "✅ Resolution complete"
583598 echo "=================================="
584599 build-dashboard-image :
585- if : needs.resolve-dashboard-image.outputs.needs_build == 'true'
586600 needs : resolve-dashboard-image
601+ if : |
602+ !cancelled() &&
603+ needs.resolve-dashboard-image.result == 'success' &&
604+ needs.resolve-dashboard-image.outputs.needs_build == 'true'
587605 runs-on : ${{ vars.DEFAULT_RUNNER }}
588606 permissions :
589607 id-token : write
@@ -762,9 +780,12 @@ jobs:
762780 echo "image=$IMAGE" >> $GITHUB_OUTPUT
763781 echo "✅ Dashboard image built and pushed: $IMAGE"
764782 test-controller-api :
765- if : github.event.pull_request.draft == false
766783 needs :
767784 - goreleaser
785+ if : |
786+ !cancelled() &&
787+ needs.goreleaser.result == 'success' &&
788+ github.event.pull_request.draft == false
768789 runs-on : ${{ vars.DEFAULT_RUNNER }}
769790 outputs :
770791 envfiles : ${{ steps.params.outputs.envfiles }}
@@ -784,9 +805,9 @@ jobs:
784805 - goreleaser
785806 - resolve-dashboard-image
786807 - build-dashboard-image
787- # build-dashboard-image may be skipped, so use if: always () to run regardless
808+ # build-dashboard-image may be skipped, so use !cancelled () to run regardless
788809 if : |
789- always () &&
810+ !cancelled () &&
790811 needs.test-controller-api.result == 'success' &&
791812 needs.goreleaser.result == 'success' &&
792813 needs.resolve-dashboard-image.result == 'success' &&
@@ -862,7 +883,7 @@ jobs:
862883 name : Aggregated CI Status
863884 runs-on : ${{ vars.DEFAULT_RUNNER }}
864885 # Dynamically determine which jobs to depend on based on repository configuration
865- needs : [goreleaser, api-tests]
886+ needs : [goreleaser, api-tests, dep-guard ]
866887 if : ${{ always() && github.event_name == 'pull_request' }}
867888 steps :
868889 - name : Aggregate results
@@ -889,9 +910,12 @@ jobs:
889910
890911 echo "✅ All required jobs succeeded"
891912 test-controller-distros :
892- if : github.event.pull_request.draft == false
893913 needs :
894914 - goreleaser
915+ if : |
916+ !cancelled() &&
917+ needs.goreleaser.result == 'success' &&
918+ github.event.pull_request.draft == false
895919 runs-on : ${{ vars.DEFAULT_RUNNER }}
896920 outputs :
897921 deb : ${{ steps.params.outputs.deb }}
@@ -916,6 +940,9 @@ jobs:
916940 runs-on : ${{ vars.DEFAULT_RUNNER }}
917941 needs :
918942 - test-controller-distros
943+ if : |
944+ !cancelled() &&
945+ needs.test-controller-distros.result == 'success'
919946 strategy :
920947 fail-fast : true
921948 matrix :
@@ -975,6 +1002,9 @@ jobs:
9751002 runs-on : ${{ vars.DEFAULT_RUNNER }}
9761003 needs :
9771004 - test-controller-distros
1005+ if : |
1006+ !cancelled() &&
1007+ needs.test-controller-distros.result == 'success'
9781008 strategy :
9791009 fail-fast : true
9801010 matrix :
@@ -1028,6 +1058,9 @@ jobs:
10281058 release-tests :
10291059 needs :
10301060 - goreleaser
1061+ if : |
1062+ !cancelled() &&
1063+ needs.goreleaser.result == 'success'
10311064 permissions :
10321065 id-token : write # This is required for requesting the JWT
10331066 contents : read # This is required for actions/checkout
@@ -1036,6 +1069,9 @@ jobs:
10361069 secrets : inherit
10371070 sbom :
10381071 needs : goreleaser
1072+ if : |
1073+ !cancelled() &&
1074+ needs.goreleaser.result == 'success'
10391075 uses : TykTechnologies/github-actions/.github/workflows/sbom.yaml@42304edda365365e0a887cf018d8edc34b960b82 # main
10401076 secrets :
10411077 DEPDASH_URL : ${{ secrets.DEPDASH_URL }}
0 commit comments