Files
coredns-mysql/.gitea/workflows/image.yaml
T
bryanpedini 94e55db7c8
Build and update CoreDNS MySQL / image (push) Successful in 33s
ci: skip build and publish when upstream versions are unchanged
2026-11-09 23:22:33 +01:00

72 lines
2.9 KiB
YAML

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
id: update
if: github.event_name != 'push'
run: |
set -eu
python3 scripts/update.py
if git diff --quiet -- versions.env; then echo changed=false; else echo changed=true; fi >> "$GITHUB_OUTPUT"
- name: Build and test
if: github.event_name == 'push' || steps.update.outputs.changed == 'true'
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' && steps.update.outputs.changed == 'true'
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
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
if: github.event_name == 'push' || steps.update.outputs.changed == 'true'
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"