@@ -161,6 +161,27 @@ jobs:
161161 fail-on-alert : false
162162 max-items-in-chart : 100
163163
164+ # Validates that a nightly tag's embedded date matches today's UTC date.
165+ # Prevents stale or replayed nightly tags from triggering scenario tests.
166+ validate-nightly-tag :
167+ runs-on : ubuntu-latest
168+ if : startsWith(github.ref, 'refs/tags/v') && contains(github.ref_name, '-nightly.')
169+ outputs :
170+ is_current : ${{ steps.check.outputs.is_current }}
171+ steps :
172+ - name : Check nightly tag date matches today (UTC)
173+ id : check
174+ run : |
175+ tag_date=$(echo "${{ github.ref_name }}" | grep -oP '(?<=-nightly\.)\d{8}')
176+ today_utc=$(date -u +%Y%m%d)
177+ echo "Tag date: $tag_date"
178+ echo "Today (UTC): $today_utc"
179+ if [[ "$tag_date" == "$today_utc" ]]; then
180+ echo "is_current=true" >> $GITHUB_OUTPUT
181+ else
182+ echo "::warning::Nightly tag date ($tag_date) does not match today's UTC date ($today_utc). Skipping scenario tests."
183+ fi
184+
164185 # End-to-end tests that target a network deployment.
165186 # We run this every release (at minimum, nightly), or when explicitly requested.
166187 # This task runs against a real testnet deployment. This uses resources on GCP (not AWS, thank free credit incentives).
@@ -174,9 +195,17 @@ jobs:
174195 fail-fast : false
175196 matrix :
176197 test_set : ["1", "2"]
177- # We run on nightly tags only, or when the ci-network-scenario label is present in a PR.
178- needs : ci
179- if : github.event.pull_request.head.repo.fork != true && github.event.pull_request.draft == false && ((startsWith(github.ref, 'refs/tags/v') && contains(github.ref_name, '-nightly.')) || contains(github.event.pull_request.labels.*.name, 'ci-network-scenario'))
198+ # We run on current nightly tags only, or when the ci-network-scenario label is present in a PR.
199+ needs : [ci, validate-nightly-tag]
200+ if : |
201+ always()
202+ && (needs.ci.result == 'success' || needs.ci.result == 'skipped')
203+ && github.event.pull_request.head.repo.fork != true
204+ && github.event.pull_request.draft == false
205+ && (
206+ needs.validate-nightly-tag.outputs.is_current == 'true'
207+ || contains(github.event.pull_request.labels.*.name, 'ci-network-scenario')
208+ )
180209 steps :
181210 - name : Remove label (one-time use)
182211 if : github.event.pull_request && contains(github.event.pull_request.labels.*.name, 'ci-network-scenario')
0 commit comments