This commit is contained in:
2025-12-24 00:26:56 -07:00
parent 69ab6265a9
commit e6fb87c574
2 changed files with 31 additions and 1 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
name: Build Coredns with netboxdns plugin
on: [push]
on: [workflow_dispatch]
jobs:
build:
+30
View File
@@ -2,8 +2,14 @@
set -xeuo pipefail
main() {
# Location to persist build metadata between runs (use Actions cache on this). [web:51][web:52]
BUILD_STATE_DIR="${BUILD_STATE_DIR:-${GITHUB_WORKSPACE:-.}/.build-state}"
mkdir -p "${BUILD_STATE_DIR}"
META_FILE="${BUILD_STATE_DIR}/coredns-netboxdns.meta"
GO_VERSION=$(curl -s 'https://go.dev/VERSION?m=text' | head -n1)
ACTION_REPO_DIR="${PWD}"
ACTION_COMMIT="$(git rev-parse HEAD)"
# 2. Create temp directory
TMPDIR="$(mktemp -d)"
@@ -33,6 +39,22 @@ main() {
git fetch --tags --depth=1 origin "${COREDNS_LATEST_VERSION}"
git checkout "${COREDNS_LATEST_VERSION}"
echo "CoreDNS version (tag): ${LATEST_TAG}"
echo "Action repo commit : ${ACTION_COMMIT}"
# 4b. Skip build if same CoreDNS version and same action repo commit as last time. # NEW
if [ -f "${META_FILE}" ]; then
LAST_COREDNS_TAG="$(sed -n 's/^COREDNS_TAG=//p' "${META_FILE}")"
LAST_ACTION_COMMIT="$(sed -n 's/^ACTION_COMMIT=//p' "${META_FILE}")"
if [ "${LAST_COREDNS_TAG}" = "${COREDNS_LATEST_VERSION}" ] &&
[ "${LAST_ACTION_COMMIT}" = "${ACTION_COMMIT}" ]; then
echo "No changes in CoreDNS version or action repo commit since last build."
echo "Skipping build and upload."
exit 0
fi
fi
# 5. Update plugin.cfg to include netboxdns plugin
# Insert netboxdns after the 'cache' plugin entry as recommended.
if ! grep -q '^netboxdns:' plugin.cfg; then
@@ -110,6 +132,14 @@ EOF
--upload-file "${DEB_OUT}" \
"${DEB_REGISTRY_URL}"
# 13. Store metadata for next run (so it can be used with actions/cache). # NEW
cat >"${META_FILE}" <<EOF
COREDNS_TAG=${COREDNS_LATEST_VERSION}
ACTION_COMMIT=${ACTION_COMMIT}
EOF
echo "Updated build metadata at ${META_FILE}"
}
main "$@"