Skip to content

build(redis)

build(redis) #33

Workflow file for this run

name: build(redis)
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
pull_request:
types:
- opened
- synchronize
- reopened
paths:
- 'redis/**'
push:
branches:
- main
paths:
- 'redis/**'
workflow_dispatch:
schedule:
- cron: '0 0 3 * *'
jobs:
redis:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
name: ['redis']
suite: ['debian', 'alpine']
version: ['6.2', '7.0', '7.2', '7.4', '7.4-rc']
latest_version: ['7.4']
steps:
- name: Checkout ${{ matrix.name }}
uses: actions/checkout@v5
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get Version
run: |
echo "build=true" >> $GITHUB_ENV
if [ ! -f "${{ matrix.name }}/${{ matrix.version }}/${{ matrix.suite }}/Dockerfile" ]; then
echo "build=false" >> $GITHUB_ENV
exit 0
fi
full_version=$(grep -m1 -oP "ENV REDIS_VERSION \K.*" ${{ matrix.name }}/${{ matrix.version }}/${{ matrix.suite }}/Dockerfile)
echo "full_version=${full_version}" >> $GITHUB_ENV
version=${{ matrix.version }}
image_tag=${version}
full_image_tag=${full_version}
case ${{ matrix.suite }} in
debian)
image_tag=${version}-trixie
full_image_tag=${full_version}-trixie
;;
alpine)
image_tag=${version}-alpine3.21
full_image_tag=${full_version}-alpine3.21
;;
esac
echo "image_tag=${image_tag}" >> $GITHUB_ENV
echo "full_image_tag=${full_image_tag}" >> $GITHUB_ENV
- name: Build and push image
if: env.build == 'true'
uses: docker/build-push-action@v6
with:
context: ${{ matrix.name }}/${{ matrix.version }}/${{ matrix.suite }}/
platforms: linux/loong64
push: ${{ github.event_name != 'pull_request' }}
tags: |
ghcr.io/${{ github.repository_owner }}/${{ matrix.name }}:${{ env.image_tag }}
ghcr.io/${{ github.repository_owner }}/${{ matrix.name }}:${{ env.full_image_tag }}
ghcr.io/${{ github.repository_owner }}/${{ matrix.name }}:${{ matrix.version }}-${{ matrix.suite }}
ghcr.io/${{ github.repository_owner }}/${{ matrix.name }}:${{ env.full_version }}-${{ matrix.suite }}
outputs: type=image,oci-mediatypes=true,compression=zstd,compression-level=3,force-compression=true
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Prepare configuration
run: |
wget -qO- https://github.com/google/go-containerregistry/releases/latest/download/go-containerregistry_Linux_x86_64.tar.gz | sudo tar -xzf - -C /usr/local/bin/ crane
sudo chmod +x /usr/local/bin/crane
sudo chown root:root /usr/local/bin/crane
- name: Pull and Push Images
if: (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main'
run: |
if [ "${{ matrix.suite }}" = "debian" ] && [ "${{ matrix.version }}" = "${{ matrix.latest_version }}" ]; then
full_version=${{ env.full_version }}
minor_version=$(echo ${full_version} | cut -d'.' -f1-2)
major_version=$(echo ${full_version} | cut -d'.' -f1)
crane cp ghcr.io/${{ github.repository_owner }}/${{ matrix.name }}:${{ matrix.version }}-${{ matrix.suite }} ghcr.io/${{ github.repository_owner }}/${{ matrix.name }}:latest
crane cp ghcr.io/${{ github.repository_owner }}/${{ matrix.name }}:${{ matrix.version }}-${{ matrix.suite }} ghcr.io/${{ github.repository_owner }}/${{ matrix.name }}:${full_version}
crane cp ghcr.io/${{ github.repository_owner }}/${{ matrix.name }}:${{ matrix.version }}-${{ matrix.suite }} ghcr.io/${{ github.repository_owner }}/${{ matrix.name }}:${minor_version}
crane cp ghcr.io/${{ github.repository_owner }}/${{ matrix.name }}:${{ matrix.version }}-${{ matrix.suite }} ghcr.io/${{ github.repository_owner }}/${{ matrix.name }}:${major_version}
fi