Skip to content

Commit 64d85e5

Browse files
authored
feat(ci/cd): add support for not production release (#412)
* feat: enhance image generation workflow with prerelease option for Docker builds * fix: update SHORT_SHA assignment in image generation workflow for improved clarity
1 parent dd4306d commit 64d85e5

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

.github/workflows/image-generations.yml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ on:
55
branches:
66
- main
77
workflow_dispatch:
8+
inputs:
9+
prerelease:
10+
description: "Generate prerelease build with branch name and snapshot tags"
11+
required: false
12+
default: false
13+
type: boolean
814

915
env:
1016
TAG_NAME: latest
@@ -33,10 +39,14 @@ jobs:
3339
password: ${{ github.token }}
3440

3541
- name: Add SHORT_SHA env property with commit short sha
36-
run: echo "SHORT_SHA=${GITHUB_SHA::8}" >> $GITHUB_ENV
42+
run: echo "SHORT_SHA=$(echo $GITHUB_SHA | cut -c1-8)" >> $GITHUB_ENV
3743

38-
- name: Build and push Docker image
44+
- name: Add BRANCH_NAME env property with branch name
45+
run: echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
46+
47+
- name: Build and push Docker image (release)
3948
uses: docker/build-push-action@v5
49+
if: ${{ inputs.prerelease == 'false' }}
4050
with:
4151
context: .
4252
file: ./${{ matrix.app }}/Dockerfile
@@ -47,3 +57,17 @@ jobs:
4757
cache-from: type=gha
4858
cache-to: type=gha,mode=max
4959
platforms: linux/amd64
60+
61+
- name: Build and push Docker image (prerelease)
62+
uses: docker/build-push-action@v5
63+
if: ${{ inputs.prerelease == 'true' }}
64+
with:
65+
context: .
66+
file: ./${{ matrix.app }}/Dockerfile
67+
push: true
68+
tags: |
69+
ghcr.io/${{ github.repository_owner }}/auto-drive-${{ matrix.app }}:${{ env.BRANCH_NAME }}
70+
ghcr.io/${{ github.repository_owner }}/auto-drive-${{ matrix.app }}:snapshot-${{ env.SHORT_SHA }}
71+
cache-from: type=gha
72+
cache-to: type=gha,mode=max
73+
platforms: linux/amd64

0 commit comments

Comments
 (0)