Skip to content

Commit 2d14bd8

Browse files
committed
Refactor GitHub Actions workflow: removed unused input parameters for versioning and reference type, streamlined build process by directly using GitHub context variables, and consolidated Docker build and push steps for improved clarity and efficiency.
1 parent d8cc8f2 commit 2d14bd8

File tree

1 file changed

+6
-45
lines changed

1 file changed

+6
-45
lines changed

.github/workflows/service_docker-build-and-publish.yml

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,14 @@ on:
88
required: true
99
description: 'Release type (latest, beta, edge, dev, etc)'
1010
default: 'edge'
11-
version:
12-
type: string
13-
required: false
14-
description: 'Version to build (e.g. 1.0.0)'
15-
default: "${{ github.ref_name }}"
16-
ref_type:
17-
type: string
18-
required: false
19-
description: 'Trigger type (tag or branch)'
20-
default: "${{ github.ref_type }}"
21-
ref:
22-
type: string
23-
required: false
24-
description: 'Ref to build (e.g. v1.0.0)'
25-
default: ''
11+
2612
jobs:
2713

2814
build-and-push:
2915
runs-on: ubuntu-24.04
3016
steps:
3117
- name: Check out code.
3218
uses: actions/checkout@v4
33-
with:
34-
ref: ${{ inputs.ref }}
3519

3620
- name: Login to DockerHub
3721
uses: docker/login-action@v3
@@ -55,9 +39,9 @@ jobs:
5539
- name: Set REPOSITORY_BUILD_VERSION
5640
id: set_version
5741
run: |
58-
if [ "${{ inputs.ref_type }}" == "tag" ]; then
42+
if [ "${{ github.ref_type }}" == "tag" ]; then
5943
echo "🚀 Setting REPOSITORY_BUILD_VERSION to Tag"
60-
echo "REPOSITORY_BUILD_VERSION=${{ inputs.version }}-${{ github.run_id }}" >> $GITHUB_ENV
44+
echo "REPOSITORY_BUILD_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
6145
else
6246
echo "👨‍🔬 Setting REPOSITORY_BUILD_VERSION to GIT Short SHA and GitHub Run ID"
6347
SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7)
@@ -66,41 +50,18 @@ jobs:
6650
6751
- name: "📦 Assemble the Docker Tags"
6852
run: |
69-
if [ "${{ inputs.ref_type }}" == "tag" ]; then
53+
if [ "${{ github.ref_type }}" == "tag" ]; then
7054
bash build.sh \
7155
--release-type ${{ inputs.release_type }} \
72-
--version ${{ inputs.version }} \
56+
--version ${{ github.ref_name }} \
7357
--print-tags-only
7458
else
7559
bash build.sh \
7660
--release-type ${{ inputs.release_type }} \
7761
--print-tags-only
7862
fi
7963
80-
- name: Build and export to Docker
81-
uses: docker/build-push-action@v6
82-
with:
83-
file: src/Dockerfile
84-
cache-from: type=gha,mode=max
85-
cache-to: type=gha,mode=max
86-
platforms: linux/amd64 # Only build amd64 for scanning
87-
pull: true
88-
push: false
89-
load: true # Load into Docker's local image store
90-
tags: ${{ env.DOCKER_TAGS }}
91-
92-
- name: Run Trivy vulnerability scanner
93-
uses: aquasecurity/trivy-action@0.29.0
94-
with:
95-
image-ref: ${{ env.DOCKER_TAGS }}
96-
format: 'table'
97-
exit-code: 1
98-
ignore-unfixed: true
99-
severity: 'CRITICAL,HIGH'
100-
hide-progress: true
101-
102-
- name: Build and push all platforms
103-
if: success()
64+
- name: Build and push
10465
uses: docker/build-push-action@v6
10566
with:
10667
file: src/Dockerfile

0 commit comments

Comments
 (0)