Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

fix(ci): keep version bumps behind green checks

Juan Denisdd59a84619a7
diff --git a/.github/workflows/scripts-ci.yml b/.github/workflows/scripts-ci.yml
index a46a27da..0d70670e 100644
--- a/.github/workflows/scripts-ci.yml
+++ b/.github/workflows/scripts-ci.yml
@@ -23,6 +23,7 @@ on:
- 'serverkit'
- '.github/workflows/main-promotion.yml'
- '.github/workflows/release.yml'
+ - '.github/workflows/version-bump.yml'
- '.github/workflows/scripts-ci.yml'
pull_request:
branches: [main]
@@ -34,6 +35,7 @@ on:
- 'serverkit'
- '.github/workflows/main-promotion.yml'
- '.github/workflows/release.yml'
+ - '.github/workflows/version-bump.yml'
- '.github/workflows/scripts-ci.yml'
workflow_call:
diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml
index 1939bd48..c1c7b95f 100644
--- a/.github/workflows/version-bump.yml
+++ b/.github/workflows/version-bump.yml
@@ -11,11 +11,15 @@ on:
jobs:
bump-version:
runs-on: ubuntu-latest
+ timeout-minutes: 45
# Skip if commit message contains [skip ci] or [skip version]
if: "!contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[skip version]') && !startsWith(github.event.head_commit.message, 'chore: bump version')"
permissions:
+ actions: read
contents: write
+ pull-requests: read
+ statuses: write
steps:
- name: Checkout
@@ -95,18 +99,108 @@ jobs:
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "New version: $NEW_VERSION"
+ # A GITHUB_TOKEN push deliberately does not start another workflow run.
+ # Advancing dev immediately therefore used to replace the tested PR head
+ # with an untested VERSION-only commit. Wait for every sibling run on the
+ # triggering SHA first; on a red commit, do not advance dev at all.
+ - name: Wait for sibling CI before advancing dev
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: |
+ deadline=$((SECONDS + 2400))
+ settled_polls=0
+
+ while [ "$SECONDS" -lt "$deadline" ]; do
+ runs_file="$RUNNER_TEMP/serverkit-sibling-runs.json"
+ gh run list \
+ --repo "$GITHUB_REPOSITORY" \
+ --commit "$GITHUB_SHA" \
+ --limit 100 \
+ --json workflowName,event,status,conclusion,url \
+ > "$runs_file"
+
+ relevant=$(jq '[.[] | select(
+ .workflowName != "Version Bump"
+ and .workflowName != "Discord Notify"
+ )]' "$runs_file")
+ failed=$(jq -r '.[] | select(
+ .status == "completed"
+ and .conclusion != "success"
+ and .conclusion != "skipped"
+ and .conclusion != "neutral"
+ ) | "\(.workflowName) [\(.event)]: \(.conclusion) — \(.url)"' \
+ <<< "$relevant")
+ if [ -n "$failed" ]; then
+ echo "::error::Sibling CI failed; VERSION will not advance."
+ printf '%s\n' "$failed"
+ exit 1
+ fi
+
+ pending=$(jq '[.[] | select(.status != "completed")] | length' \
+ <<< "$relevant")
+ total=$(jq 'length' <<< "$relevant")
+ echo "Sibling CI: $total discovered, $pending still running"
+
+ if [ "$pending" -eq 0 ]; then
+ settled_polls=$((settled_polls + 1))
+ # Three quiet polls prevent a just-created push/PR run from being
+ # missed before GitHub has indexed it for `gh run list`.
+ if [ "$settled_polls" -ge 3 ]; then
+ break
+ fi
+ else
+ settled_polls=0
+ fi
+ sleep 10
+ done
+
+ if [ "$SECONDS" -ge "$deadline" ]; then
+ echo "::error::Timed out waiting for sibling CI; VERSION will not advance."
+ exit 1
+ fi
+
- name: Update VERSION file
run: |
echo "${{ steps.new.outputs.version }}" > VERSION
cat VERSION
- name: Commit and push
+ id: commit
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add VERSION
git commit -m "chore: bump version to ${{ steps.new.outputs.version }} [skip ci]"
git push
+ echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
+
+ # The bot push cannot fire Main Promotion either. Publish the exact
+ # required context only after sibling CI passed and an open same-repo
+ # dev -> main promotion was verified. This keeps strict branch protection
+ # attached to the generated head instead of the now-parent commit.
+ - name: Preserve the promotion gate on the generated commit
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ NEW_SHA: ${{ steps.commit.outputs.sha }}
+ run: |
+ owner="${GITHUB_REPOSITORY%%/*}"
+ pr_number=$(gh api --method GET "repos/$GITHUB_REPOSITORY/pulls" \
+ -f state=open \
+ -f base=main \
+ -f head="$owner:dev" \
+ --jq '.[0].number // empty')
+
+ if [ -z "$pr_number" ]; then
+ echo "No open dev -> main promotion; no promotion status is needed."
+ exit 0
+ fi
+
+ gh api --method POST "repos/$GITHUB_REPOSITORY/statuses/$NEW_SHA" \
+ -f state=success \
+ -f context='Require dev source' \
+ -f description='Sibling CI passed; verified same-repository dev -> main promotion' \
+ -f target_url="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
+ echo "Published Require dev source for PR #$pr_number at $NEW_SHA"
- name: Create summary
env:
diff --git a/scripts/test/test_release_workflow.sh b/scripts/test/test_release_workflow.sh
index 870b9fd5..21aca2ea 100644
--- a/scripts/test/test_release_workflow.sh
+++ b/scripts/test/test_release_workflow.sh
@@ -6,6 +6,7 @@ set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
RELEASE="$ROOT/.github/workflows/release.yml"
PROMOTION="$ROOT/.github/workflows/main-promotion.yml"
+VERSION_BUMP="$ROOT/.github/workflows/version-bump.yml"
failures=0
expect_text() {
@@ -43,6 +44,17 @@ expect_text "$PROMOTION" '[ "$HEAD_BRANCH" != "dev" ]' \
expect_text "$PROMOTION" '[ "$HEAD_REPOSITORY" != "$REPOSITORY" ]' \
'main promotion rejects a fork branch named dev'
+expect_text "$VERSION_BUMP" 'name: Wait for sibling CI before advancing dev' \
+ 'version bump waits for the checks on the triggering commit'
+expect_text "$VERSION_BUMP" '.workflowName != "Version Bump"' \
+ 'version bump excludes its own in-progress run from the sibling gate'
+expect_text "$VERSION_BUMP" 'statuses: write' \
+ 'version bump may preserve the required status on its generated commit'
+expect_text "$VERSION_BUMP" "-f context='Require dev source'" \
+ 'generated version commit receives the protected promotion context'
+expect_text "$VERSION_BUMP" '-f head="$owner:dev"' \
+ 'promotion status requires an open same-repository dev head'
+
expect_text "$RELEASE" 'name: Verify dev promotion' \
'release verifies the merged promotion'
expect_absent "$RELEASE" 'workflow_dispatch:' \