Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/actions/get-build-number/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Allocate build number
description: Run the released allocator against the PR head while leaving the build commit unchanged
outputs:
BUILD_NUMBER:
description: The build number claimed or reused for this workflow run
value: ${{ steps.allocate.outputs.BUILD_NUMBER }}
runs:
using: composite
steps:
- uses: SonarSource/vault-action-wrapper@881045d830534a70ec3c7c275fa3714412c8ff6e # 3.6.1
id: legacy-token
continue-on-error: true
with:
secrets: development/github/token/{REPO_OWNER_NAME_DASH}-build-number token | github_token;
- name: Allocate against the PR head
id: allocate
shell: bash
env:
GH_TOKEN: ${{ github.token }}
BUILD_NUMBER_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
LEGACY_PROPERTY_TOKEN: ${{ steps.legacy-token.outputs.vault && fromJSON(steps.legacy-token.outputs.vault).github_token || '' }}
run: |
allocator_dir=$(mktemp -d "$RUNNER_TEMP/build-number.XXXXXX")
trap 'rm -rf "$allocator_dir"' EXIT
# Use the released v2 implementation; only its process receives the alternate SHA.
gh api 'repos/SonarSource/ci-github-actions/contents/get-build-number/get_build_number.sh?ref=62463382a24f2004ffa20adbe9985f6459e031e6' \
--jq .content | base64 --decode > "$allocator_dir/allocate.sh"
GITHUB_SHA="$BUILD_NUMBER_SHA" BUILD_NUMBER_FILE="$allocator_dir/number" \
bash "$allocator_dir/allocate.sh"
build_number=$(cat "$allocator_dir/number")
[[ "$build_number" =~ ^[0-9]+$ ]] || { echo 'Invalid build number' >&2; exit 1; }
echo "BUILD_NUMBER=$build_number" >> "$GITHUB_OUTPUT"
4 changes: 1 addition & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ jobs:
version: 2026.10.10
- name: Allocate build number
id: build-number
uses: SonarSource/ci-github-actions/get-build-number@cf2fe6f1f61c0ba87a28f7f907fbad7703747299 # PR #362: PR-head bookkeeping refs
with:
ref-sha: ${{ github.event.pull_request.head.sha || github.sha }}
uses: ./.github/actions/get-build-number
- uses: SonarSource/ci-github-actions/build-gradle@v2
env:
BUILD_NUMBER: ${{ steps.build-number.outputs.BUILD_NUMBER }}
Expand Down
Loading