feat: add coredns mysql image build and updater

This commit is contained in:
bryanpedini committed 2026-11-09 22:57:47 +01:00
1 parent c3ab4cfb70
commit 6835e480c1
7 files changed
+195 -1

No files matched your search

+66
View File
@@ -0,0 +1,66 @@
name: Build and update CoreDNS MySQL
on:
push:
branches: [main]
schedule:
- cron: '0 2 * * *'
workflow_dispatch:
concurrency:
group: coredns-mysql
cancel-in-progress: false
jobs:
image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Check upstream versions
if: github.event_name != 'push'
run: python3 scripts/update.py
- name: Build and test
run: |
set -eu
. ./versions.env
docker build --pull --build-arg COREDNS_VERSION="$COREDNS_VERSION" --build-arg MYSQL_PLUGIN_REV="$MYSQL_PLUGIN_REV" -f dockerfile -t coredns-mysql:ci .
scripts/test-image.sh coredns-mysql:ci "$COREDNS_VERSION"
- name: Commit and push updated versions
if: github.event_name != 'push'
env:
GIT_HOST: ${{ vars.GIT_HOST }}
GIT_NAME: ${{ vars.GIT_NAME }}
GIT_EMAIL: ${{ vars.GIT_EMAIL }}
REGISTRY_USER: ${{ vars.REGISTRY_USER }}
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
run: |
set -eu
if git diff --quiet -- versions.env; then exit 0; fi
test -n "$GIT_HOST" && test -n "$GIT_NAME" && test -n "$GIT_EMAIL" && test -n "$REGISTRY_USER" && test -n "$GIT_TOKEN"
git config user.name "$GIT_NAME"
git config user.email "$GIT_EMAIL"
git add versions.env
git commit -m 'chore: update upstream versions'
askpass=$(mktemp)
trap 'rm -f "$askpass"' EXIT
printf '%s\n' '#!/bin/sh' 'case "$1" in *Username*) printf "%s\\n" "$REGISTRY_USER" ;; *) printf "%s\\n" "$GIT_TOKEN" ;; esac' > "$askpass"
chmod 700 "$askpass"
GIT_ASKPASS="$askpass" GIT_TERMINAL_PROMPT=0 git push "https://${GIT_HOST}/${GITHUB_REPOSITORY}.git" HEAD:refs/heads/main
- name: Publish image
env:
GIT_HOST: ${{ vars.GIT_HOST }}
REGISTRY_USER: ${{ vars.REGISTRY_USER }}
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
run: |
set -eu
test -n "$GIT_HOST" && test -n "$REGISTRY_USER" && test -n "$GIT_TOKEN"
. ./versions.env
image="${GIT_HOST}/docker/coredns-mysql"
printf '%s' "$GIT_TOKEN" | docker login "$GIT_HOST" --username "$REGISTRY_USER" --password-stdin
trap 'docker logout "$GIT_HOST" >/dev/null 2>&1 || true' EXIT
docker tag coredns-mysql:ci "${image}:${COREDNS_VERSION}"
docker tag coredns-mysql:ci "${image}:latest"
docker push "${image}:${COREDNS_VERSION}"
docker push "${image}:latest"