67 lines
2.6 KiB
YAML
67 lines
2.6 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
|
|
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"
|