From 6f0d10c99e787f88647e24d1e42609fd04db26c7 Mon Sep 17 00:00:00 2001 From: Ben Vincent Date: Sat, 25 Jan 2025 16:42:27 +1100 Subject: [PATCH] feat: add build workflows - enable fetch-depth for code_checkout - fetch master branch before checking for changed files - ensure the clean target is called with the default --- .gitea/workflows/build.yaml | 31 +++++++++++++++++++++++++++++ .gitea/workflows/deploy.yaml | 38 ++++++++++++++++++++++++++++++++++++ Makefile | 2 +- ci/build.sh | 1 + 4 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 .gitea/workflows/build.yaml create mode 100644 .gitea/workflows/deploy.yaml diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml new file mode 100644 index 0000000..441beb8 --- /dev/null +++ b/.gitea/workflows/build.yaml @@ -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 diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml new file mode 100644 index 0000000..0d155c2 --- /dev/null +++ b/.gitea/workflows/deploy.yaml @@ -0,0 +1,38 @@ +name: Deploy + +on: + push: + branches: + - master + +jobs: + build: + runs-on: almalinux-8 + container: + image: git.query.consul/unkin/almalinux8:latest + options: --privileged + + steps: + - name: Set up environment + run: | + dnf install -y yum-utils + yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo + dnf module enable -y nodejs:20 + dnf install -y docker-ce-cli make bash git nodejs + + - 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 diff --git a/Makefile b/Makefile index f3678f6..fe14123 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/ci/build.sh b/ci/build.sh index f8be9e2..46fe8ca 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -1,6 +1,7 @@ #!/bin/bash # Check for changes in images/ folder and the builds/ folder +git fetch origin master:master if [ "$(git branch --show-current)" = "master" ]; then builds_changes=$(git diff --name-only HEAD^...master | grep -E '^builds/') images_changes=$(git diff --name-only HEAD^...master | grep -E '^images/')