Skip to content

GitHub CI

GitHub CI #327

Workflow file for this run

name: GitHub CI
on:
pull_request:
push:
paths:
- '**/Dockerfile*'
schedule:
- cron: '0 0 * * *'
defaults:
run:
shell: 'bash -Eeuo pipefail -x {0}'
jobs:
generate-jobs:
name: Generate Jobs
runs-on: ubuntu-latest
outputs:
strategy: ${{ steps.generate-jobs.outputs.strategy }}
steps:
- uses: actions/checkout@v4
- uses: docker-library/bashbrew@v0.1.12
- id: generate-jobs
name: Generate Jobs
run: |
strategy="$("$BASHBREW_SCRIPTS/github-actions/generate.sh")"
# If triggered by a cron event, filter strategy to include `unstable` and `unstable-alpine`
if [[ "${{ github.event_name }}" == "schedule" ]]; then
strategy=$(jq -c '{"fail-fast": .["fail-fast"],"matrix":{"include":[ .matrix.include[]|select(.name =="unstable" or .name== "unstable-alpine")]}}' <<<"$strategy")
fi
echo "strategy=$strategy" >> "$GITHUB_OUTPUT"
jq . <<<"$strategy" # sanity check / debugging aid
test:
needs: generate-jobs
strategy: ${{ fromJson(needs.generate-jobs.outputs.strategy) }}
name: ${{ matrix.name }} - test
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Prepare Environment
run: ${{ matrix.runs.prepare }}
- name: Pull Dependencies
run: ${{ matrix.runs.pull }}
- name: Build ${{ matrix.name }}
run: ${{ matrix.runs.build }}
- name: History ${{ matrix.name }}
run: ${{ matrix.runs.history }}
- name: Test ${{ matrix.name }}
run: ${{ matrix.runs.test }}
- name: '"docker images"'
run: ${{ matrix.runs.images }}
build_and_push:
if: |
((github.event_name == 'push' || github.event_name == 'schedule') &&
github.ref == 'refs/heads/mainline')
needs:
- generate-jobs
- test
strategy: ${{ fromJson(needs.generate-jobs.outputs.strategy) }}
name: ${{ matrix.name }} - Build and push
runs-on: ${{ matrix.os }}
steps:
# Tags are created by generate.sh in the format `valkey-container:<tag>`
# This step modifies the tags to `account/valkey:<tag>` to be provided to build-push github action.
- name: Modify Tags
id: modify_tags
run: |
original_tags="${{ toJson(matrix.meta.entries[0].tags) }}"
tags=$(echo $original_tags | sed 's/valkey-container/${{ secrets.DOCKERHUB_ACCOUNT }}\/valkey/g'| sed 's/\[ *//; s/ *\]//; s/ //g')
echo "modified_tags=$tags" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
file: ./${{ matrix.meta.entries[0].directory }}/Dockerfile
push: true
tags: ${{ steps.modify_tags.outputs.modified_tags }}
platforms: linux/amd64,linux/arm64,linux/arm/v7
provenance: false
load: false
update-dockerhub-description:
if: |
(github.event_name == 'push' && github.ref == 'refs/heads/mainline')
needs:
- generate-jobs
- test
- build_and_push
name: Update DockerHub Description
uses: ./.github/workflows/update-dockerhub-docs.yml
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
DOCKERHUB_REPOSITORY: ${{ secrets.DOCKERHUB_REPOSITORY }}