Skip to content

Commit 3ee01af

Browse files
committed
MON-195572 Switch to workflow_dispatch with upstream_ref and image_tags inputs
1 parent 439d0c4 commit 3ee01af

1 file changed

Lines changed: 34 additions & 29 deletions

File tree

.github/workflows/centreon-publish-docker-images.yml

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,26 @@ name: Centreon - Publish Docker Images to Harbor
22

33
# This workflow is Centreon-specific and separate from the upstream publish_docker_images.yml.
44
# It publishes multi-arch images (amd64 + arm64) to Centreon's internal Harbor registry.
5-
#
6-
# Tagging strategy:
7-
# - push on main → :qual
8-
# - git tag centreon-v* → :<tag> (e.g. centreon-v1.2.3)
9-
# - pull_request → :<sanitized-branch-name>
5+
# Triggered manually with a specific upstream git ref and custom image tags.
106

117
on:
12-
push:
13-
branches:
14-
- main
15-
paths:
16-
- "quickwit/**"
17-
- ".github/workflows/centreon-publish-docker-images.yml"
18-
tags:
19-
- "centreon-v*"
20-
pull_request:
21-
paths:
22-
- "quickwit/**"
23-
- ".github/workflows/centreon-publish-docker-images.yml"
8+
workflow_dispatch:
9+
inputs:
10+
upstream_ref:
11+
description: 'Git ref to build (branch, tag, or commit SHA)'
12+
required: true
13+
default: 'main'
14+
type: string
15+
image_tags:
16+
description: 'Docker image tags (comma-separated, e.g.: qual,1.2.3,latest)'
17+
required: true
18+
type: string
2419

2520
permissions:
2621
contents: read
2722

2823
env:
29-
REGISTRY_IMAGE: ${{ vars.DOCKER_REGISTRY_BASE_URL }}/pulse/quickwit
24+
REGISTRY_IMAGE: ${{ vars.DOCKER_HARBOR_HOST }}/pulse/quickwit
3025

3126
jobs:
3227
docker:
@@ -56,11 +51,14 @@ jobs:
5651
5752
- name: Checkout
5853
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
54+
with:
55+
ref: ${{ inputs.upstream_ref }}
56+
fetch-depth: 0
5957

6058
- name: Login to Harbor
6159
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
6260
with:
63-
registry: ${{ vars.DOCKER_REGISTRY_BASE_URL }}
61+
registry: ${{ vars.DOCKER_HARBOR_HOST }}
6462
username: ${{ secrets.HARBOR_CENTREON_PUSH_USERNAME }}
6563
password: ${{ secrets.HARBOR_CENTREON_PUSH_TOKEN }}
6664

@@ -117,25 +115,32 @@ jobs:
117115
path: /tmp/digests
118116
merge-multiple: true
119117

120-
- name: Sanitize branch name for PR tagging
121-
if: github.event_name == 'pull_request'
122-
run: |
123-
echo "BRANCH_TAG=${GITHUB_HEAD_REF//\//-}" >> $GITHUB_ENV
124-
125118
- name: Set up Docker Buildx
126119
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
127120

121+
- name: Build tags for Docker meta
122+
id: build_tags
123+
run: |
124+
TAGS=""
125+
IFS=',' read -ra TAG_LIST <<< "${{ inputs.image_tags }}"
126+
for tag in "${TAG_LIST[@]}"; do
127+
tag=$(echo "$tag" | xargs)
128+
TAGS+="type=raw,value=${tag}"$'\n'
129+
done
130+
{
131+
echo 'tags<<EOF'
132+
printf '%s' "$TAGS"
133+
echo 'EOF'
134+
} >> "$GITHUB_OUTPUT"
135+
128136
- name: Docker meta
129137
id: meta
130138
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
131139
with:
132140
images: ${{ env.REGISTRY_IMAGE }}
133141
flavor: |
134142
latest=false
135-
tags: |
136-
type=raw,value=qual,enable=${{ github.ref == 'refs/heads/main' }}
137-
type=ref,event=tag,enable=${{ startsWith(github.ref, 'refs/tags/centreon-v') }}
138-
type=raw,value=${{ env.BRANCH_TAG }},enable=${{ github.event_name == 'pull_request' }}
143+
tags: ${{ steps.build_tags.outputs.tags }}
139144
labels: |
140145
org.opencontainers.image.title=Quickwit
141146
org.opencontainers.image.vendor=Centreon
@@ -144,7 +149,7 @@ jobs:
144149
- name: Login to Harbor
145150
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
146151
with:
147-
registry: ${{ vars.DOCKER_REGISTRY_BASE_URL }}
152+
registry: ${{ vars.DOCKER_HARBOR_HOST }}
148153
username: ${{ secrets.HARBOR_CENTREON_PUSH_USERNAME }}
149154
password: ${{ secrets.HARBOR_CENTREON_PUSH_TOKEN }}
150155

0 commit comments

Comments
 (0)