Skip to content

Commit dcc3de4

Browse files
committed
Add build args, custom_build and test workflows
- Added build args in dockerfile for moduels and redis version - Added custom_build input to use in dockerfile and build-and-tag-locally - Created test workflow to run unsable build
1 parent fe29f68 commit dcc3de4

File tree

7 files changed

+94
-38
lines changed

7 files changed

+94
-38
lines changed

.github/actions/apply-docker-version/apply-docker-version.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,19 @@ update_dockerfile() {
5757
echo "Updating $dockerfile..."
5858

5959
# Update REDIS_DOWNLOAD_URL
60-
if grep -q "^ENV REDIS_DOWNLOAD_URL=" "$dockerfile"; then
61-
sed -i "s|^ENV REDIS_DOWNLOAD_URL=.*|ENV REDIS_DOWNLOAD_URL=$REDIS_ARCHIVE_URL|" "$dockerfile"
60+
if grep -q "^ARG REDIS_DOWNLOAD_URL=" "$dockerfile"; then
61+
sed -i "s|^ARG REDIS_DOWNLOAD_URL=.*|ARG REDIS_DOWNLOAD_URL=$REDIS_ARCHIVE_URL|" "$dockerfile"
6262
else
63-
echo "Cannot update $dockerfile, ENV REDIS_DOWNLOAD_URL not found"
63+
echo "Cannot update $dockerfile, ARG REDIS_DOWNLOAD_URL not found"
6464
return 1
6565
fi
6666

6767

6868
# Update REDIS_DOWNLOAD_SHA
69-
if grep -q "^ENV REDIS_DOWNLOAD_SHA=" "$dockerfile"; then
70-
sed -i "s|^ENV REDIS_DOWNLOAD_SHA=.*|ENV REDIS_DOWNLOAD_SHA=$REDIS_ARCHIVE_SHA|" "$dockerfile"
69+
if grep -q "^ARG REDIS_DOWNLOAD_SHA=" "$dockerfile"; then
70+
sed -i "s|^ARG REDIS_DOWNLOAD_SHA=.*|ARG REDIS_DOWNLOAD_SHA=$REDIS_ARCHIVE_SHA|" "$dockerfile"
7171
else
72-
echo "Cannot update $dockerfile, ENV REDIS_DOWNLOAD_SHA not found"
72+
echo "Cannot update $dockerfile, ARG REDIS_DOWNLOAD_SHA not found"
7373
return 1
7474
fi
7575
}

.github/actions/build-and-tag-locally/action.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ inputs:
3535
redistimeseries_version:
3636
description: 'Redistimeseries version to build'
3737
required: false
38+
custom_build:
39+
description: 'Type of custom release, branch tag or commit. Empty for release'
40+
required: false
3841

3942
runs:
4043
using: "composite"
@@ -100,6 +103,21 @@ runs:
100103
username: ${{ inputs.registry_username }}
101104
password: ${{ inputs.registry_password }}
102105

106+
- name: Redis release archive
107+
shell: bash
108+
if: inputs.custom_build != ''
109+
run: |
110+
if [[ "${{ inputs.custom_build }}" == "branch" ]]; then
111+
echo "REDIS_DOWNLOAD_URL=https://github.com/redis/redis/archive/refs/heads/${{ inputs.release_tag }}.tar.gz" >> "$GITHUB_ENV"
112+
elif [[ "${{ inputs.custom_build }}" == "tag" ]]; then
113+
echo "REDIS_DOWNLOAD_URL=https://github.com/redis/redis/archive/refs/tags/${{ inputs.release_tag }}.tar.gz" >> "$GITHUB_ENV"
114+
elif [[ "${{ inputs.custom_build }}" == "commit" ]]; then
115+
echo "REDIS_DOWNLOAD_URL=https://github.com/redis/redis/archive/${{ inputs.release_tag }}.tar.gz" >> "$GITHUB_ENV"
116+
else
117+
echo "Wrong custom_build, available options are tag, branch and "commit"
118+
exit 1
119+
fi
120+
103121
- name: Build
104122
uses: docker/build-push-action@v6
105123
with:
@@ -115,6 +133,7 @@ runs:
115133
REDISJSON_VERSION=${{ inputs.redisjson_version }}
116134
REDISBLOOM_VERSION=${{ inputs.redisbloom_version }}
117135
REDISTIMESERIES_VERSION=${{ inputs.redistimeseries_version }}
136+
${{ inputs.custom_build != '' && format('CUSTOM_BUILD=true\nREDIS_DOWNLOAD_URL={0}', env.REDIS_DOWNLOAD_URL) || '' }}
118137
119138
- name: Run container
120139
shell: bash
@@ -267,6 +286,7 @@ runs:
267286
REDISJSON_VERSION=${{ inputs.redisjson_version }}
268287
REDISBLOOM_VERSION=${{ inputs.redisbloom_version }}
269288
REDISTIMESERIES_VERSION=${{ inputs.redistimeseries_version }}
289+
${{ inputs.custom_build != '' && format('CUSTOM_BUILD=true\nREDIS_DOWNLOAD_URL={0}', env.REDIS_DOWNLOAD_URL) || '' }}
270290
labels: |
271291
${{ steps.get-image-labels.outputs.image_labels }}
272292
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}

.github/workflows/pre-merge.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ on:
3232
required: false
3333
type: boolean
3434
default: false
35+
custom_build:
36+
description: 'Run type, either branch, tag or commit. Empty for releases'
37+
required: false
38+
type: string
3539
outputs:
3640
docker_images_metadata:
3741
description: 'Array of structured Docker images metadata that were published'
@@ -73,7 +77,7 @@ jobs:
7377
|| ''
7478
}}
7579
- name: Ensure release branch
76-
if: inputs.release_tag != '' && inputs.release_tag != 'unstable'
80+
if: inputs.release_tag != '' && inputs.release_tag != 'unstable' && inputs.custom_build == ''
7781
uses: redis-developer/redis-oss-release-automation/.github/actions/ensure-release-branch@main
7882
with:
7983
release_tag: ${{ inputs.release_tag }}
@@ -91,6 +95,7 @@ jobs:
9195
redisjson_version: ${{ inputs.redisjson_version }}
9296
redisbloom_version: ${{ inputs.redisbloom_version }}
9397
redistimeseries_version: ${{ inputs.redistimeseries_version }}
98+
custom_build: ${{ inputs.custom_build }}
9499

95100
collect-images-metadata:
96101
runs-on: ubuntu-latest
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Test Nightly Unstable Build and Package
2+
on:
3+
push:
4+
branches:
5+
- unstable-alignment
6+
7+
jobs:
8+
build-and-test-unstable:
9+
uses: redis/docker-library-redis/.github/workflows/pre-merge.yml
10+
with:
11+
release_tag: unstable
12+
redisearch_version: master
13+
redisjson_version: master
14+
redisbloom_version: master
15+
redistimeseries_version: master
16+
publish_image: false
17+
custom_build: branch

.github/workflows/unstable.yml

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

alpine/Dockerfile

Lines changed: 20 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

debian/Dockerfile

Lines changed: 25 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)