Compare commits

3 Commits

Author SHA1 Message Date
unkinben 27b95e2fca test: debug
Build / build (pull_request) Successful in 6s
2025-01-25 17:29:49 +11:00
unkinben 7a1d25f3b6 feat: add build workflows
Build / build (pull_request) Successful in 7s
- 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
2025-01-25 17:14:28 +11:00
unkinben d936a21108 feat: remove incus from builds file
- this will prevent incus images from building
- pending physical build nodes before enabling deployment of incus images
2025-01-25 17:08:30 +11:00
7 changed files with 79 additions and 13 deletions
+31
View File
@@ -0,0 +1,31 @@
name: Build
on:
pull_request:
jobs:
build:
runs-on: almalinux-8
container:
image: git.query.consul/unkin/almalinux9-actionsdind:latest
options: --privileged
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Fetch master branch
run: |
git fetch origin master:master
- name: Show changed files
run: |
git diff --name-only master
- name: Run Packer Builds
env:
VAULT_ROLEID: ${{ secrets.PACKER_BUILDER_VAULT_ROLEID }}
run: |
make
+31
View File
@@ -0,0 +1,31 @@
name: Deploy
on:
push:
branches:
- master
jobs:
build:
runs-on: almalinux-8
container:
image: git.query.consul/unkin/almalinux9-actionsdind:latest
options: --privileged
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Fetch master branch
run: |
git fetch origin master:master
- name: Run Packer Builds
env:
VAULT_ROLEID: ${{ secrets.PACKER_BUILDER_VAULT_ROLEID }}
DOCKER_USERNAME: ${{ secrets.UPLOAD_USER }}
DOCKER_PASSWORD: ${{ secrets.UPLOAD_PASS }}
run: |
make
+15 -9
View File
@@ -17,7 +17,7 @@ DIRS := $(shell find $(IMAGES_PATH) -mindepth 3 -maxdepth 3 -type d | sed 's|$(I
.PHONY: list $(DIRS) .PHONY: list $(DIRS)
.DEFAULT_GOAL := default .DEFAULT_GOAL := default
default: default: clean
./ci/build.sh ./ci/build.sh
# Make all images # Make all images
@@ -39,12 +39,16 @@ $(DIRS):
@echo "Building for $@" @echo "Building for $@"
# Export environment # Export environment
export VAULT_TOKEN=$$(vault write -field=token auth/approle/login role_id=$$VAULT_ROLEID) export VAULT_ADDR=https://vault.query.consul:8200
export VAULT_ADDR=https://vault.service.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)"') eval $$(vault kv get -format=json kv/service/packer/builder/env | jq -r '.data.data | to_entries[] | "export \(.key)=\(.value)"')
@echo "Environment retrieved for $@"
env | grep -i CONSUL
env | grep -i VAULT
# Check if on master branch # Check if on master branch
@if [ "$(GIT_BRANCH)" = "master" ]; then \ if [ "$(GIT_BRANCH)" = "master" ]; then \
echo "Current branch is $(GIT_BRANCH), checking latest timestamp in consul."; \ echo "Current branch is $(GIT_BRANCH), checking latest timestamp in consul."; \
LAST_BUILD_TIMESTAMP=$$(consul kv get infra/packer/$@/timestamp || echo "0"); \ LAST_BUILD_TIMESTAMP=$$(consul kv get infra/packer/$@/timestamp || echo "0"); \
CURRENT_TIME=$$(date +%s); \ CURRENT_TIME=$$(date +%s); \
@@ -58,15 +62,17 @@ $(DIRS):
fi fi
# Link .hcl files # Link .hcl files
@find $(LIBRARY_PATH) -name '*.hcl' -exec sh -c 'ln -sf $$PWD/{} $(IMAGES_PATH)/$@/$(SYMLINK_PREFIX)$$(basename {})' \; @echo "Linking .hcl files for $@"
find $(LIBRARY_PATH) -name '*.hcl' -exec sh -c 'ln -sf $$PWD/{} $(IMAGES_PATH)/$@/$(SYMLINK_PREFIX)$$(basename {})' \;
# Link builds # Link builds
@for build in $$(cat $(IMAGES_PATH)/$@/builds); do \ @echo "Linking build files for $@"
for build in $$(cat $(IMAGES_PATH)/$@/builds); do \
ln -sf ../../../../builds/$${build}.pkr.hcl $(IMAGES_PATH)/$@/library_$${build}.build.pkr.hcl; \ ln -sf ../../../../builds/$${build}.pkr.hcl $(IMAGES_PATH)/$@/library_$${build}.build.pkr.hcl; \
done done
# Build the image # Build the image
@(cd $(IMAGES_PATH)/$@ && \ (cd $(IMAGES_PATH)/$@ && \
export DATE=$(DATE_TAG) && \ export DATE=$(DATE_TAG) && \
export OS_NAME=$$(echo $@ | cut -d'/' -f1) && \ export OS_NAME=$$(echo $@ | cut -d'/' -f1) && \
export OS_VERSION_FULL=$$(echo $@ | cut -d'/' -f2) && \ export OS_VERSION_FULL=$$(echo $@ | cut -d'/' -f2) && \
@@ -82,7 +88,7 @@ $(DIRS):
packer build . ) packer build . )
# Update build timestamp and date in Consul if on master branch # Update build timestamp and date in Consul if on master branch
@if [ "$(GIT_BRANCH)" = "master" ]; then \ if [ "$(GIT_BRANCH)" = "master" ]; then \
echo "Current branch is $(GIT_BRANCH), updating consul."; \ echo "Current branch is $(GIT_BRANCH), updating consul."; \
CURRENT_TIMESTAMP=$$(date +%s); \ CURRENT_TIMESTAMP=$$(date +%s); \
READABLE_DATE=$$(date '+%Y-%m-%d %H:%M:%S %Z'); \ READABLE_DATE=$$(date '+%Y-%m-%d %H:%M:%S %Z'); \
-1
View File
@@ -1,2 +1 @@
docker docker
incus
@@ -1,7 +1,7 @@
# almalinux/8.10/base # almalinux/8.10/base
deploy_files_from_image = true deploy_files_from_image = true
deploy_files_from_common = true deploy_files_from_common = true
use_incus = true use_incus = false
packages = [ packages = [
"git", "git",
"jq", "jq",
-1
View File
@@ -1,2 +1 @@
docker docker
incus
@@ -1,7 +1,7 @@
# almalinux/9.5/base # almalinux/9.5/base
deploy_files_from_image = true deploy_files_from_image = true
deploy_files_from_common = true deploy_files_from_common = true
use_incus = true use_incus = false
packages = [ packages = [
"git", "git",
"jq", "jq",