modified: .gitea/workflows/deploy.yml
This commit is contained in:
@@ -8,6 +8,7 @@ on:
|
|||||||
- '**.yml'
|
- '**.yml'
|
||||||
- '**.yaml'
|
- '**.yaml'
|
||||||
schedule:
|
schedule:
|
||||||
|
# Runs every Friday at 00:00 UTC
|
||||||
- cron: '0 0 * * 5'
|
- cron: '0 0 * * 5'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
@@ -15,9 +16,13 @@ jobs:
|
|||||||
build-and-push:
|
build-and-push:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
- name: Prepare Git for SHA256 Repo
|
||||||
|
run: git config --global init.defaultObjectFormat sha256
|
||||||
|
|
||||||
- name: Checkout Code
|
- name: Checkout Code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
|
# Fetch full history to allow git diff comparisons between commits
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
@@ -41,35 +46,35 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
FILES_TO_BUILD=""
|
FILES_TO_BUILD=""
|
||||||
|
|
||||||
# 1. Determine the trigger type
|
# 1. Check the event type triggering the action
|
||||||
if [ "${{ github.event_name }}" = "schedule" ] || [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
if [ "${{ github.event_name }}" = "schedule" ] || [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||||
echo "Scheduled or manual run triggered. Processing all YAML files..."
|
echo "Scheduled or manual run triggered. Processing all YAML files..."
|
||||||
# Find all .yml and .yaml files, excluding the workflow file itself
|
# Find all root-level YAML configuration files
|
||||||
FILES_TO_BUILD=$(find . -maxdepth 1 -name "*.yml" -o -name "*.yaml")
|
FILES_TO_BUILD=$(find . -maxdepth 1 -name "*.yml" -o -name "*.yaml")
|
||||||
else
|
else
|
||||||
echo "Push triggered. Detecting changed files..."
|
echo "Push triggered. Detecting changed files..."
|
||||||
# Get list of added/modified files in this push commit
|
# Isolate only the added or modified YAML files in the current push event
|
||||||
FILES_TO_BUILD=$(git diff-tree --no-commit-id --name-only -r ${{ github.sha }} | grep -E '\.(yml|yaml)$' || true)
|
FILES_TO_BUILD=$(git diff-tree --no-commit-id --name-only -r ${{ github.sha }} | grep -E '\.(yml|yaml)$' || true)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 2. Process each detected file
|
# 2. Loop through and compile each matched configuration file
|
||||||
for file in $FILES_TO_BUILD; do
|
for file in $FILES_TO_BUILD; do
|
||||||
# Clean path string and ensure file still exists (handles deleted files safely)
|
# Clean string structures and confirm the physical file path still exists
|
||||||
file=$(echo "$file" | sed 's|^\./||')
|
file=$(echo "$file" | sed 's|^\./||')
|
||||||
if [ ! -f "$file" ]; then continue; fi
|
if [ ! -f "$file" ]; then continue; fi
|
||||||
|
|
||||||
# Skip the workflow directory completely
|
# Skip workflow files to avoid self-building cycles
|
||||||
if [[ "$file" == .gitea/* ]]; then continue; fi
|
if [[ "$file" == .gitea/* ]]; then continue; fi
|
||||||
|
|
||||||
# Extract the filename without path and without extension
|
# Strip paths and extensions (e.g., 'nginx.yml' becomes 'nginx')
|
||||||
filename=$(basename -- "$file")
|
filename=$(basename -- "$file")
|
||||||
image_name="${filename%.*}"
|
image_name="${filename%.*}"
|
||||||
|
|
||||||
echo "---------------------------------------------------"
|
echo "---------------------------------------------------"
|
||||||
echo "Processing: $file -> Image target: $image_name:latest"
|
echo "Processing: $file -> Target: registry.chillcog.com/${image_name}:latest"
|
||||||
echo "---------------------------------------------------"
|
echo "---------------------------------------------------"
|
||||||
|
|
||||||
# Execute the DHI BuildKit build and push natively via CLI
|
# Execute the DHI BuildKit routine and route to the local target registry
|
||||||
docker buildx build \
|
docker buildx build \
|
||||||
--push \
|
--push \
|
||||||
--no-cache \
|
--no-cache \
|
||||||
|
|||||||
Reference in New Issue
Block a user