Skip to content

Commit 8ad0787

Browse files
committed
ci: refactor Docker build and push workflow and remove unused workflows
1 parent fa4541b commit 8ad0787

File tree

3 files changed

+48
-87
lines changed

3 files changed

+48
-87
lines changed

.github/workflows/build-and-push.yml

Lines changed: 48 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
11
name: Build and Publish Docker Image
2-
32
on:
43
workflow_dispatch:
54
inputs:
6-
release_tag:
7-
description: "Release version to build"
5+
container_version:
6+
description: "Container version to build (e.g., 1.2.3 or 1.2.3-beta)"
7+
required: true
8+
photon_version:
9+
description: "Photon version"
810
required: true
9-
revision:
10-
description: "Revision number (optional)"
11-
required: false
11+
branch:
12+
description: "Branch to build from"
13+
required: true
14+
default: "main"
15+
type: choice
16+
options:
17+
- main
18+
- dev
1219

1320
jobs:
1421
build-and-push:
1522
runs-on: ubuntu-latest
1623
steps:
1724
- name: Checkout Repository
1825
uses: actions/checkout@v4
26+
with:
27+
ref: ${{ github.event.inputs.branch }}
1928

2029
- name: Set up Docker Buildx
2130
uses: docker/setup-buildx-action@v3
@@ -33,31 +42,47 @@ jobs:
3342
username: ${{ github.repository_owner }}
3443
password: ${{ secrets.GITHUB_TOKEN }}
3544

36-
- name: Determine tag
37-
id: determine_tag
45+
- name: Determine version and tags
46+
id: determine_tags
3847
run: |
39-
revision="${{ github.event.inputs.revision }}"
40-
if [ "$revision" ]; then
41-
echo "RELEASE_TAG=${{ github.event.inputs.release_tag }}-rev.$revision" >> "$GITHUB_ENV"
48+
CONTAINER_VERSION="${{ github.event.inputs.container_version }}"
49+
PHOTON_VERSION="${{ github.event.inputs.photon_version }}"
50+
51+
CONTAINER_VERSION="${CONTAINER_VERSION#v}"
52+
53+
if [[ "$CONTAINER_VERSION" == *"-beta"* ]] || [ "${{ github.event.inputs.branch }}" == "dev" ]; then
54+
IS_PRERELEASE="true"
55+
else
56+
IS_PRERELEASE="false"
57+
fi
58+
59+
echo "CONTAINER_VERSION=$CONTAINER_VERSION" >> "$GITHUB_ENV"
60+
echo "PHOTON_VERSION=$PHOTON_VERSION" >> "$GITHUB_ENV"
61+
echo "IS_PRERELEASE=$IS_PRERELEASE" >> "$GITHUB_ENV"
62+
63+
TAGS="rtuszik/photon-docker:$CONTAINER_VERSION"
64+
TAGS="$TAGS,ghcr.io/rtuszik/photon-docker:$CONTAINER_VERSION"
65+
66+
if [ "$IS_PRERELEASE" == "true" ]; then
67+
TAGS="$TAGS,rtuszik/photon-docker:beta"
68+
TAGS="$TAGS,ghcr.io/rtuszik/photon-docker:beta"
4269
else
43-
echo "RELEASE_TAG=${{ github.event.inputs.release_tag }}" >> "$GITHUB_ENV"
70+
TAGS="$TAGS,rtuszik/photon-docker:latest"
71+
TAGS="$TAGS,ghcr.io/rtuszik/photon-docker:latest"
4472
fi
45-
echo "PHOTON_VERSION=${{ github.event.inputs.release_tag }}" >> "$GITHUB_ENV"
73+
74+
echo "DOCKER_TAGS=$TAGS" >> "$GITHUB_ENV"
75+
76+
echo "Container Version: $CONTAINER_VERSION"
77+
echo "Photon Version: $PHOTON_VERSION"
78+
echo "Is Prerelease: $IS_PRERELEASE"
79+
echo "Tags: $TAGS"
4680
4781
- name: Build and push Docker image
4882
uses: docker/build-push-action@v6
4983
with:
5084
build-args: |
5185
PHOTON_VERSION=${{ env.PHOTON_VERSION }}
5286
push: true
53-
tags: |
54-
rtuszik/photon-docker:${{ env.RELEASE_TAG }}
55-
rtuszik/photon-docker:latest
56-
ghcr.io/rtuszik/photon-docker:${{ env.RELEASE_TAG }}
57-
ghcr.io/rtuszik/photon-docker:latest
87+
tags: ${{ env.DOCKER_TAGS }}
5888
platforms: linux/amd64,linux/arm64
59-
60-
- name: Store the latest release
61-
run: echo ${{ env.RELEASE_TAG }} > .last_release
62-
if: success()
63-
continue-on-error: false

.github/workflows/index_sync.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

.github/workflows/sonarqube.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)