From e6fb87c57417e956f7fc4779f0f909418b462b60 Mon Sep 17 00:00:00 2001 From: restitux Date: Wed, 24 Dec 2025 00:26:56 -0700 Subject: [PATCH] TEST --- .gitea/workflows/build-release.yml | 2 +- ci/build.sh | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/build-release.yml b/.gitea/workflows/build-release.yml index e69f355..1ec07a8 100644 --- a/.gitea/workflows/build-release.yml +++ b/.gitea/workflows/build-release.yml @@ -1,5 +1,5 @@ name: Build Coredns with netboxdns plugin -on: [push] +on: [workflow_dispatch] jobs: build: diff --git a/ci/build.sh b/ci/build.sh index 0851908..b7853a5 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -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}" <