feat: add build workflows
Build / build (pull_request) Successful in 2m6s

- enable fetch-depth for code_checkout
- fetch master branch before checking for changed files
- ensure the clean target is called with the default
- improve makefile failure handling
- ensure VAULT_ADDR is set before VAULT_TOKEN
This commit is contained in:
2025-01-25 16:42:27 +11:00
parent d936a21108
commit 8f3493b69d
5 changed files with 77 additions and 11 deletions
+9 -7
View File
@@ -8,7 +8,7 @@ REGISTRY := git.query.consul
OWNER := unkin
DATE_TAG := $(shell date +%Y%m%d)
SUFFIX=$(shell basename $$(mktemp -u) | cut -d . -f 2)
GIT_BRANCH=$(shell git branch --show-current)
GIT_BRANCH=$(shell git symbolic-ref --short HEAD 2>/dev/null || echo $$GITHUB_HEAD_REF)
GIT_COMMIT := $(shell git rev-parse --short HEAD)
# Find all subdirectories under the IMAGES_PATH
@@ -17,7 +17,7 @@ DIRS := $(shell find $(IMAGES_PATH) -mindepth 3 -maxdepth 3 -type d | sed 's|$(I
.PHONY: list $(DIRS)
.DEFAULT_GOAL := default
default:
default: clean
./ci/build.sh
# Make all images
@@ -39,9 +39,11 @@ $(DIRS):
@echo "Building for $@"
# Export environment
export VAULT_TOKEN=$$(vault write -field=token auth/approle/login role_id=$$VAULT_ROLEID)
export VAULT_ADDR=https://vault.service.consul:8200
@eval $$(vault kv get -format=json kv/service/packer/builder/env | jq -r '.data.data | to_entries[] | "export \(.key)=\(.value)"')
export VAULT_ADDR=https://vault.query.consul:8200
export VAULT_TOKEN=$$(vault write -field=token auth/approle/login role_id=$$VAULT_ROLEID) && \
eval $$(vault kv get -format=json kv/service/packer/builder/env | jq -r '.data.data | to_entries[] | "export \(.key)=\(.value)"')
@echo "Environment retrieved for $@"
# Check if on master branch
@if [ "$(GIT_BRANCH)" = "master" ]; then \
@@ -78,8 +80,8 @@ $(DIRS):
export SUFFIX=$(SUFFIX) && \
export GIT_COMMIT=$(GIT_COMMIT) && \
export GIT_BRANCH=$(GIT_BRANCH) && \
packer init . && \
packer build . )
/usr/bin/packer init . && \
/usr/bin/packer build . )
# Update build timestamp and date in Consul if on master branch
@if [ "$(GIT_BRANCH)" = "master" ]; then \