Skip to content

Commit 7365314

Browse files
committed
SONAR-25648 refactor config loading
1 parent 62ea217 commit 7365314

12 files changed

+224
-48
lines changed

.github/github_env.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Central configuration for GitHub Actions workflows
2+
# This file contains all version numbers and common configurations used across workflows
3+
4+
versions:
5+
current: "2025.4.1"
6+
previous_lta: "9.9.9"
7+
community_build: "25.7.0.110598"
8+
9+
images:
10+
staging: "sonarsource/sonarqube"
11+
public: "sonarqube"
12+
13+
registries:
14+
gcp_public: "gcr.io/sonarsource-public"
15+
gcp_staging: "gcr.io/sonarqube-marketplace-provider"
16+
17+
products:
18+
gcp_public_name: "official-sonarqube-data-center-edition"
19+
gcp_staging_name: "sonarqube-dce-staging"
20+
21+
# Build matrix definitions
22+
matrix:
23+
lta_builds:
24+
- version: "9/community"
25+
edition: "community"
26+
- version: "9/developer"
27+
edition: "developer"
28+
- version: "9/enterprise"
29+
edition: "enterprise"
30+
- version: "9/datacenter/app"
31+
edition: "datacenter-app"
32+
- version: "9/datacenter/search"
33+
edition: "datacenter-search"
34+
35+
current_builds:
36+
- version: "commercial-editions/developer"
37+
edition: "developer"
38+
- version: "commercial-editions/enterprise"
39+
edition: "enterprise"
40+
- version: "commercial-editions/datacenter/app"
41+
edition: "datacenter-app"
42+
- version: "commercial-editions/datacenter/search"
43+
edition: "datacenter-search"

.github/workflows/gcp-build-production.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ on:
1717
types: [published]
1818

1919
jobs:
20+
load-config:
21+
uses: ./.github/workflows/load-config.yml
22+
2023
gcp-build-production-app:
24+
needs: load-config
2125
permissions:
2226
id-token: write
2327
contents: read
@@ -28,15 +32,16 @@ jobs:
2832
(github.event_name == 'workflow_dispatch' && github.event.inputs.trigger_type == 'PUSH_GCP_PROD_IMAGES')
2933
uses: ./.github/workflows/gcp-build-template.yml
3034
with:
31-
gcp_registry: gcr.io/sonarsource-public
32-
gcp_product_name: official-sonarqube-data-center-edition
35+
gcp_registry: ${{ needs.load-config.outputs.gcp_public_registry }}
36+
gcp_product_name: ${{ needs.load-config.outputs.gcp_public_product }}
3337
build_type: production
3438
platforms: linux/amd64
35-
current_version: 2025.4.1
36-
public_image_name: sonarqube
39+
current_version: ${{ needs.load-config.outputs.current_version }}
40+
public_image_name: ${{ needs.load-config.outputs.public_image }}
3741
component_type: app
3842

3943
gcp-build-production-search:
44+
needs: load-config
4045
permissions:
4146
id-token: write
4247
contents: read
@@ -47,10 +52,10 @@ jobs:
4752
(github.event_name == 'workflow_dispatch' && github.event.inputs.trigger_type == 'PUSH_GCP_PROD_IMAGES')
4853
uses: ./.github/workflows/gcp-build-template.yml
4954
with:
50-
gcp_registry: gcr.io/sonarsource-public
51-
gcp_product_name: official-sonarqube-data-center-edition
55+
gcp_registry: ${{ needs.load-config.outputs.gcp_public_registry }}
56+
gcp_product_name: ${{ needs.load-config.outputs.gcp_public_product }}
5257
build_type: production
5358
platforms: linux/amd64
54-
current_version: 2025.4.1
55-
public_image_name: sonarqube
59+
current_version: ${{ needs.load-config.outputs.current_version }}
60+
public_image_name: ${{ needs.load-config.outputs.public_image }}
5661
component_type: search

.github/workflows/gcp-build-staging.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ on:
1818
- PUSH_GCP_STAGING_IMAGES
1919

2020
jobs:
21+
load-config:
22+
uses: ./.github/workflows/load-config.yml
23+
2124
gcp-build-staging-app:
25+
needs: load-config
2226
if: |
2327
github.event_name == 'schedule' ||
2428
(github.event_name == 'workflow_dispatch' && github.event.inputs.trigger_type == 'PUSH_GCP_STAGING_IMAGES') ||
@@ -29,15 +33,16 @@ jobs:
2933
name: GCP build staging (app)
3034
uses: ./.github/workflows/gcp-build-template.yml
3135
with:
32-
gcp_registry: gcr.io/sonarqube-marketplace-provider
33-
gcp_product_name: sonarqube-dce-staging
36+
gcp_registry: ${{ needs.load-config.outputs.gcp_staging_registry }}
37+
gcp_product_name: ${{ needs.load-config.outputs.gcp_staging_product }}
3438
build_type: staging
3539
platforms: linux/amd64,linux/arm64
3640
extra_docker_build_args: "--provenance=false --annotation=manifest,manifest-descriptor:com.googleapis.cloudmarketplace.product.service.name=services/official-sonarqube-data-center-edition.endpoints.sonarsource-public.cloud.goog"
37-
current_version: 2025.4.1
41+
current_version: ${{ needs.load-config.outputs.current_version }}
3842
component_type: app
3943

4044
gcp-build-staging-search:
45+
needs: load-config
4146
if: |
4247
github.event_name == 'schedule' ||
4348
(github.event_name == 'workflow_dispatch' && github.event.inputs.trigger_type == 'PUSH_GCP_STAGING_IMAGES') ||
@@ -48,10 +53,10 @@ jobs:
4853
name: GCP build staging (search)
4954
uses: ./.github/workflows/gcp-build-template.yml
5055
with:
51-
gcp_registry: gcr.io/sonarqube-marketplace-provider
52-
gcp_product_name: sonarqube-dce-staging
56+
gcp_registry: ${{ needs.load-config.outputs.gcp_staging_registry }}
57+
gcp_product_name: ${{ needs.load-config.outputs.gcp_staging_product }}
5358
build_type: staging
5459
platforms: linux/amd64,linux/arm64
5560
extra_docker_build_args: "--provenance=false --annotation=manifest,manifest-descriptor:com.googleapis.cloudmarketplace.product.service.name=services/official-sonarqube-data-center-edition.endpoints.sonarsource-public.cloud.goog"
56-
current_version: 2025.4.1
61+
current_version: ${{ needs.load-config.outputs.current_version }}
5762
component_type: search

.github/workflows/load-config.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Load Configuration
2+
3+
on:
4+
workflow_call:
5+
outputs:
6+
current_version:
7+
description: "Current SonarQube version"
8+
value: ${{ jobs.load-config.outputs.current_version }}
9+
previous_lta_version:
10+
description: "Previous LTA version"
11+
value: ${{ jobs.load-config.outputs.previous_lta_version }}
12+
community_build_version:
13+
description: "Community build version"
14+
value: ${{ jobs.load-config.outputs.community_build_version }}
15+
staging_image:
16+
description: "Staging image name"
17+
value: ${{ jobs.load-config.outputs.staging_image }}
18+
public_image:
19+
description: "Public image name"
20+
value: ${{ jobs.load-config.outputs.public_image }}
21+
gcp_public_registry:
22+
description: "GCP public registry"
23+
value: ${{ jobs.load-config.outputs.gcp_public_registry }}
24+
gcp_staging_registry:
25+
description: "GCP staging registry"
26+
value: ${{ jobs.load-config.outputs.gcp_staging_registry }}
27+
gcp_public_product:
28+
description: "GCP public product name"
29+
value: ${{ jobs.load-config.outputs.gcp_public_product }}
30+
gcp_staging_product:
31+
description: "GCP staging product name"
32+
value: ${{ jobs.load-config.outputs.gcp_staging_product }}
33+
34+
jobs:
35+
load-config:
36+
runs-on: ubuntu-latest
37+
outputs:
38+
current_version: ${{ steps.config.outputs.current_version }}
39+
previous_lta_version: ${{ steps.config.outputs.previous_lta_version }}
40+
community_build_version: ${{ steps.config.outputs.community_build_version }}
41+
staging_image: ${{ steps.config.outputs.staging_image }}
42+
public_image: ${{ steps.config.outputs.public_image }}
43+
gcp_public_registry: ${{ steps.config.outputs.gcp_public_registry }}
44+
gcp_staging_registry: ${{ steps.config.outputs.gcp_staging_registry }}
45+
gcp_public_product: ${{ steps.config.outputs.gcp_public_product }}
46+
gcp_staging_product: ${{ steps.config.outputs.gcp_staging_product }}
47+
48+
steps:
49+
- name: Checkout repository
50+
uses: actions/checkout@v4
51+
52+
- name: Load configuration
53+
id: config
54+
run: |
55+
# Install yq for YAML parsing
56+
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
57+
sudo chmod +x /usr/local/bin/yq
58+
59+
# Extract values from github_env.yaml
60+
CURRENT_VERSION=$(yq '.versions.current' .github/github_env.yaml)
61+
PREVIOUS_LTA_VERSION=$(yq '.versions.previous_lta' .github/github_env.yaml)
62+
COMMUNITY_BUILD_VERSION=$(yq '.versions.community_build' .github/github_env.yaml)
63+
STAGING_IMAGE=$(yq '.images.staging' .github/github_env.yaml)
64+
PUBLIC_IMAGE=$(yq '.images.public' .github/github_env.yaml)
65+
GCP_PUBLIC_REGISTRY=$(yq '.registries.gcp_public' .github/github_env.yaml)
66+
GCP_STAGING_REGISTRY=$(yq '.registries.gcp_staging' .github/github_env.yaml)
67+
GCP_PUBLIC_PRODUCT=$(yq '.products.gcp_public_name' .github/github_env.yaml)
68+
GCP_STAGING_PRODUCT=$(yq '.products.gcp_staging_name' .github/github_env.yaml)
69+
70+
# Set outputs
71+
echo "current_version=${CURRENT_VERSION}" >> $GITHUB_OUTPUT
72+
echo "previous_lta_version=${PREVIOUS_LTA_VERSION}" >> $GITHUB_OUTPUT
73+
echo "community_build_version=${COMMUNITY_BUILD_VERSION}" >> $GITHUB_OUTPUT
74+
echo "staging_image=${STAGING_IMAGE}" >> $GITHUB_OUTPUT
75+
echo "public_image=${PUBLIC_IMAGE}" >> $GITHUB_OUTPUT
76+
echo "gcp_public_registry=${GCP_PUBLIC_REGISTRY}" >> $GITHUB_OUTPUT
77+
echo "gcp_staging_registry=${GCP_STAGING_REGISTRY}" >> $GITHUB_OUTPUT
78+
echo "gcp_public_product=${GCP_PUBLIC_PRODUCT}" >> $GITHUB_OUTPUT
79+
echo "gcp_staging_product=${GCP_STAGING_PRODUCT}" >> $GITHUB_OUTPUT
80+
81+
# Debug output
82+
echo "Loaded configuration:"
83+
echo " Current version: ${CURRENT_VERSION}"
84+
echo " Previous LTA: ${PREVIOUS_LTA_VERSION}"
85+
echo " Community build: ${COMMUNITY_BUILD_VERSION}"

.github/workflows/multi-arch-build-9x.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,24 @@ on:
77
- '.cirrus/multi-arch-build.sh'
88
- '.github/workflows/multi-arch-build-9x.yml'
99
- '.github/workflows/multi-arch-build-template.yml'
10+
- '.github/github_env.yaml'
1011
pull_request:
1112
paths:
1213
- '9/**/*'
1314
- '.cirrus/multi-arch-build.sh'
1415
- '.github/workflows/multi-arch-build-9x.yml'
1516
- '.github/workflows/multi-arch-build-template.yml'
17+
- '.github/github_env.yaml'
1618
schedule:
1719
- cron: '0 2 * * *'
1820
workflow_dispatch:
1921

2022
jobs:
23+
load-config:
24+
uses: ./.github/workflows/load-config.yml
25+
2126
multi-arch-build-9x:
27+
needs: load-config
2228
permissions:
2329
id-token: write
2430
contents: read
@@ -28,17 +34,17 @@ jobs:
2834
matrix:
2935
include:
3036
- version: 9/community
31-
tag: 9.9.9-master-community
37+
edition: community
3238
- version: 9/developer
33-
tag: 9.9.9-master-developer
39+
edition: developer
3440
- version: 9/enterprise
35-
tag: 9.9.9-master-enterprise
41+
edition: enterprise
3642
- version: 9/datacenter/app
37-
tag: 9.9.9-master-datacenter-app
43+
edition: datacenter-app
3844
- version: 9/datacenter/search
39-
tag: 9.9.9-master-datacenter-search
45+
edition: datacenter-search
4046
with:
41-
staging_image_name: sonarsource/sonarqube
42-
tag: ${{ matrix.tag }}
47+
staging_image_name: ${{ needs.load-config.outputs.staging_image }}
48+
tag: ${{ needs.load-config.outputs.previous_lta_version }}-master-${{ matrix.edition }}
4349
version: ${{ matrix.version }}
4450
runs_on: ubuntu-latest-large

.github/workflows/multi-arch-build-commercial-editions.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,24 @@ on:
77
- '.cirrus/multi-arch-build.sh'
88
- '.github/workflows/multi-arch-build-commercial-editions.yml'
99
- '.github/workflows/multi-arch-build-template.yml'
10+
- '.github/github_env.yaml'
1011
pull_request:
1112
paths:
1213
- 'commercial-editions/**/*'
1314
- '.cirrus/multi-arch-build.sh'
1415
- '.github/workflows/multi-arch-build-commercial-editions.yml'
1516
- '.github/workflows/multi-arch-build-template.yml'
17+
- '.github/github_env.yaml'
1618
schedule:
1719
- cron: '0 2 * * *'
1820
workflow_dispatch:
1921

2022
jobs:
23+
load-config:
24+
uses: ./.github/workflows/load-config.yml
25+
2126
multi-arch-build-commercial-editions:
27+
needs: load-config
2228
name: Build commercial editions (${{ matrix.version }})
2329
permissions:
2430
id-token: write
@@ -28,15 +34,15 @@ jobs:
2834
matrix:
2935
include:
3036
- version: commercial-editions/developer
31-
tag: 2025.4.1-master-developer
37+
edition: developer
3238
- version: commercial-editions/enterprise
33-
tag: 2025.4.1-master-enterprise
39+
edition: enterprise
3440
- version: commercial-editions/datacenter/app
35-
tag: 2025.4.1-master-datacenter-app
41+
edition: datacenter-app
3642
- version: commercial-editions/datacenter/search
37-
tag: 2025.4.1-master-datacenter-search
43+
edition: datacenter-search
3844
with:
39-
staging_image_name: sonarsource/sonarqube
40-
tag: ${{ matrix.tag }}
45+
staging_image_name: ${{ needs.load-config.outputs.staging_image }}
46+
tag: ${{ needs.load-config.outputs.current_version }}-master-${{ matrix.edition }}
4147
version: ${{ matrix.version }}
4248
runs_on: ubuntu-latest-large

.github/workflows/multi-arch-build-community-build.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,24 @@ on:
77
- '.cirrus/multi-arch-build.sh'
88
- '.github/workflows/multi-arch-build-community-build.yml'
99
- '.github/workflows/multi-arch-build-template.yml'
10+
- '.github/github_env.yaml'
1011
pull_request:
1112
paths:
1213
- 'community-build/*'
1314
- '.cirrus/multi-arch-build.sh'
1415
- '.github/workflows/multi-arch-build-community-build.yml'
1516
- '.github/workflows/multi-arch-build-template.yml'
17+
- '.github/github_env.yaml'
1618
schedule:
1719
- cron: '0 2 * * *'
1820
workflow_dispatch:
1921

2022
jobs:
23+
load-config:
24+
uses: ./.github/workflows/load-config.yml
25+
2126
multi-arch-build-community-build:
27+
needs: load-config
2228
name: Build community build (${{ matrix.version }})
2329
permissions:
2430
id-token: write
@@ -28,9 +34,9 @@ jobs:
2834
matrix:
2935
include:
3036
- version: community-build
31-
tag: 25.7.0.110598-master-community
37+
edition: community
3238
with:
33-
staging_image_name: sonarsource/sonarqube
34-
tag: ${{ matrix.tag }}
39+
staging_image_name: ${{ needs.load-config.outputs.staging_image }}
40+
tag: ${{ needs.load-config.outputs.community_build_version }}-master-${{ matrix.edition }}
3541
version: ${{ matrix.version }}
3642
runs_on: ubuntu-latest-large

.github/workflows/multi-arch-test-9x.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ on:
99
workflow_dispatch:
1010

1111
jobs:
12+
load-config:
13+
uses: ./.github/workflows/load-config.yml
14+
1215
multi-arch-test-9x:
16+
needs: load-config
1317
name: Test 9.x (${{ matrix.test_name }}, ${{ matrix.architecture }})
1418
permissions:
1519
id-token: write
@@ -21,16 +25,16 @@ jobs:
2125
architecture: [amd64, arm64]
2226
include:
2327
- test_name: docker
24-
tag: 9.9.9-master-community
28+
edition: community
2529
- test_name: docker
26-
tag: 9.9.9-master-developer
30+
edition: developer
2731
- test_name: docker
28-
tag: 9.9.9-master-enterprise
32+
edition: enterprise
2933
- test_name: docker-compose
30-
tag: 9.9.9-master-datacenter
34+
edition: datacenter
3135
with:
32-
staging_image_name: sonarsource/sonarqube
33-
tag: ${{ matrix.tag }}
36+
staging_image_name: ${{ needs.load-config.outputs.staging_image }}
37+
tag: ${{ needs.load-config.outputs.previous_lta_version }}-master-${{ matrix.edition }}
3438
test_name: ${{ matrix.test_name }}
3539
architecture: ${{ matrix.architecture }}
3640
runs_on: ${{ matrix.architecture == 'arm64' && 'ubuntu-24.04-arm-large' || 'ubuntu-24.04-large' }}

0 commit comments

Comments
 (0)