Skip to content

Commit 4d36b0e

Browse files
fix cd workflow (#389)
1 parent 1fd09cc commit 4d36b0e

File tree

1 file changed

+34
-16
lines changed

1 file changed

+34
-16
lines changed

.github/workflows/cd-ratel.yml

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ on:
66
latest:
77
type: boolean
88
default: false
9-
description: If enabled, the image will also be tagged and pushed as `latest` on DockerHub.
9+
description: If enabled, the image will be tagged and pushed as `latest` on DockerHub.
1010
releasetag:
1111
type: string
12-
description: The version tag to use for the Docker image (e.g., v21.12.0).
1312
required: true
13+
description: The version tag to use for the Docker image (e.g., v24.0.0)
1414
custom-build:
1515
type: boolean
1616
default: false
17-
description: If enabled, images will be tagged with the version tag instead of `latest`
17+
description: If enabled, image is tagged and pushed with the version only
1818

1919
permissions:
2020
contents: read
@@ -30,18 +30,33 @@ jobs:
3030
- uses: actions/checkout@v4
3131
with:
3232
ref: "${{ github.event.inputs.releasetag }}"
33+
34+
- name: Validate inputs
35+
run: |
36+
if [ "${{ github.event.inputs.custom-build }}" != "true" ] && [ "${{ github.event.inputs.latest }}" != "true" ]; then
37+
echo "Error: You must enable either 'custom-build' or 'latest'"
38+
exit 1
39+
fi
40+
3341
- name: Build Docker Image
3442
run: |
35-
echo "Building ratel with version ${BUILD_VERSION}"
36-
make build
3743
if [ "${{ github.event.inputs.latest }}" = "true" ]; then
44+
echo "Building with 'make latest'"
3845
make latest
46+
else
47+
echo "Building with 'make build'"
48+
make build
3949
fi
40-
if [ "${{ github.event.inputs.custom-build }}" = "true" ]; then
41-
docker tag dgraph/ratel:${BUILD_VERSION} dgraph/ratel-custom:${BUILD_VERSION}
42-
fi
50+
4351
- name: Save Docker Image
44-
run: docker save -o ratel-docker-image.tar dgraph/ratel:${BUILD_VERSION}
52+
run: |
53+
IMAGE_LIST="dgraph/ratel:${BUILD_VERSION}"
54+
if [ "${{ github.event.inputs.latest }}" = "true" ]; then
55+
IMAGE_LIST="$IMAGE_LIST dgraph/ratel:latest"
56+
fi
57+
echo "Saving Docker image(s): $IMAGE_LIST"
58+
docker save -o ratel-docker-image.tar $IMAGE_LIST
59+
4560
- name: Upload Build Artifacts
4661
uses: actions/upload-artifact@v4
4762
with:
@@ -56,24 +71,27 @@ jobs:
5671
- uses: actions/checkout@v4
5772
with:
5873
ref: "${{ github.event.inputs.releasetag }}"
74+
5975
- name: Login to DockerHub
6076
uses: docker/login-action@v3
6177
with:
6278
username: ${{ secrets.DOCKERHUB_USERNAME }}
6379
password: ${{ secrets.DOCKERHUB_PASSWORD_TOKEN }}
80+
6481
- name: Download Docker Image
6582
uses: actions/download-artifact@v4
6683
with:
6784
name: ratel-docker-image
85+
6886
- name: Load Docker Image
6987
run: docker load -i ratel-docker-image.tar
70-
- name: Push Docker Images
88+
89+
- name: Push Docker Image(s)
7190
run: |
72-
echo "Pushing Docker images with version ${BUILD_VERSION}"
73-
docker push dgraph/ratel:${BUILD_VERSION}
7491
if [ "${{ github.event.inputs.latest }}" = "true" ]; then
75-
docker push dgraph/ratel:latest
76-
fi
77-
if [ "${{ github.event.inputs.custom-build }}" = "true" ]; then
78-
docker push dgraph/ratel-custom:${BUILD_VERSION}
92+
echo "Pushing with make release (version + latest)"
93+
make release
94+
else
95+
echo "Pushing version-only image"
96+
make push
7997
fi

0 commit comments

Comments
 (0)