modified: .gitea/workflows/deploy.yml
This commit is contained in:
@@ -8,6 +8,7 @@ on:
|
||||
- '**.yml'
|
||||
- '**.yaml'
|
||||
schedule:
|
||||
# Runs every Friday at 00:00 UTC
|
||||
- cron: '0 0 * * 5'
|
||||
workflow_dispatch:
|
||||
|
||||
@@ -15,9 +16,13 @@ jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Prepare Git for SHA256 Repo
|
||||
run: git config --global init.defaultObjectFormat sha256
|
||||
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
# Fetch full history to allow git diff comparisons between commits
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
@@ -41,35 +46,35 @@ jobs:
|
||||
run: |
|
||||
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
|
||||
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")
|
||||
else
|
||||
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)
|
||||
fi
|
||||
|
||||
# 2. Process each detected file
|
||||
# 2. Loop through and compile each matched configuration file
|
||||
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|^\./||')
|
||||
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
|
||||
|
||||
# Extract the filename without path and without extension
|
||||
# Strip paths and extensions (e.g., 'nginx.yml' becomes 'nginx')
|
||||
filename=$(basename -- "$file")
|
||||
image_name="${filename%.*}"
|
||||
|
||||
echo "---------------------------------------------------"
|
||||
echo "Processing: $file -> Image target: $image_name:latest"
|
||||
echo "Processing: $file -> Target: registry.chillcog.com/${image_name}:latest"
|
||||
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 \
|
||||
--push \
|
||||
--no-cache \
|
||||
|
||||
Reference in New Issue
Block a user