meilisearch/.github/workflows/publish-docker-images.yml

72 lines
2.5 KiB
YAML
Raw Permalink Normal View History

---
on:
2022-06-09 17:50:20 +08:00
schedule:
- cron: '0 4 * * *' # Every day at 4:00am
push:
tags:
- '*'
2022-06-09 17:50:20 +08:00
name: Publish tagged images to Docker Hub
jobs:
docker:
2021-12-22 01:32:29 +08:00
runs-on: docker
steps:
- uses: actions/checkout@v2
# Check if the tag has the v<nmumber>.<number>.<number> format. If yes, it means we are publishing an official release.
# In this situation, we need to set `output.stable` to create/update the following tags (additionally to the `vX.Y.Z` Docker tag):
# - a `vX.Y` (without patch version) Docker tag
# - a `latest` Docker tag
- name: Check tag format
if: github.event_name != 'schedule'
id: check-tag-format
run: |
escaped_tag=$(printf "%q" ${{ github.ref_name }})
if [[ $escaped_tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo ::set-output name=stable::true
else
echo ::set-output name=stable::false
fi
# Check only the validity of the tag for official releases (not for pre-releases or other tags)
- name: Check release validity
2022-06-24 01:14:39 +08:00
if: github.event_name != 'schedule' && steps.check-tag-format.outputs.stable == 'true'
run: bash .github/scripts/check-release.sh
2021-11-11 22:57:06 +08:00
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
2021-11-11 22:57:06 +08:00
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
2021-11-11 22:57:06 +08:00
- name: Login to Docker Hub
2022-06-09 17:50:20 +08:00
if: github.event_name != 'schedule'
uses: docker/login-action@v2
2021-11-12 02:42:30 +08:00
with:
2022-06-20 20:39:50 +08:00
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
2021-11-12 02:42:30 +08:00
2021-11-11 22:57:06 +08:00
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
2021-11-11 22:57:06 +08:00
with:
2021-11-12 02:42:30 +08:00
images: getmeili/meilisearch
# The lastest and `vX.Y` tags are only pushed for the official Meilisearch releases
# See https://github.com/docker/metadata-action#latest-tag
2021-11-11 22:57:06 +08:00
flavor: latest=false
tags: |
type=ref,event=tag
2022-06-24 01:14:39 +08:00
type=semver,pattern=v{{major}}.{{minor}},enable=${{ steps.check-tag-format.outputs.stable == 'true' }}
type=raw,value=latest,enable=${{ steps.check-tag-format.outputs.stable == 'true' }}
2021-11-11 22:57:06 +08:00
- name: Build and push
id: docker_build
uses: docker/build-push-action@v3
with:
2022-06-09 17:50:20 +08:00
# We do not push tags for the cron jobs, this is only for test purposes
push: ${{ github.event_name != 'schedule' }}
2021-11-11 23:28:30 +08:00
platforms: linux/amd64,linux/arm64
2021-11-11 22:57:06 +08:00
tags: ${{ steps.meta.outputs.tags }}