eploy
This commit is contained in:
parent
e4c687fc2c
commit
446a2a089d
1 changed files with 13 additions and 11 deletions
|
|
@ -39,7 +39,7 @@ jobs:
|
|||
fi
|
||||
|
||||
if [ -z "$BASE" ]; then
|
||||
echo "No base commit found; deploying nothing."
|
||||
echo "No base commit found"
|
||||
echo "swarm_files=" >> "$GITHUB_OUTPUT"
|
||||
echo 'compose_matrix={"include":[]}' >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
|
|
@ -49,11 +49,15 @@ jobs:
|
|||
echo "Changed files:"
|
||||
echo "$CHANGED"
|
||||
|
||||
# Swarm stacks live in: swarm/*.yml|yaml
|
||||
# --------------------
|
||||
# Swarm stacks: swarm/*.yml|yaml
|
||||
# --------------------
|
||||
SWARM_FILES="$(echo "$CHANGED" | grep -E '^swarm/.*\.ya?ml$' || true)"
|
||||
echo "swarm_files=$(echo "$SWARM_FILES" | xargs)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# Compose YAMLs live in: services/compose/<host>/<service>/<file>.yml|yaml
|
||||
# --------------------
|
||||
# Compose files: services/compose/<host>/<service>/*.yml|yaml
|
||||
# --------------------
|
||||
COMPOSE_FILES="$(echo "$CHANGED" | grep -E '^services/compose/[^/]+/[^/]+/.*\.ya?ml$' || true)"
|
||||
|
||||
JSON='{"include":['
|
||||
|
|
@ -77,7 +81,7 @@ jobs:
|
|||
container:
|
||||
image: docker:27-cli
|
||||
steps:
|
||||
- name: Checkout repository (git clone, no node)
|
||||
- name: Checkout repository
|
||||
shell: sh
|
||||
env:
|
||||
CLONE_URL: ${{ github.server_url }}/${{ github.repository }}.git
|
||||
|
|
@ -96,7 +100,7 @@ jobs:
|
|||
set -e
|
||||
cd repo
|
||||
for f in ${{ needs.detect.outputs.swarm_files }}; do
|
||||
echo "Validating swarm stack file: $f"
|
||||
echo "Validating $f"
|
||||
docker stack config -c "$f" >/dev/null
|
||||
done
|
||||
|
||||
|
|
@ -107,14 +111,14 @@ jobs:
|
|||
cd repo
|
||||
for f in ${{ needs.detect.outputs.swarm_files }}; do
|
||||
STACK="$(basename "$f" | sed 's/\.ya\?ml$//')"
|
||||
echo "Deploying swarm stack: $STACK from $f"
|
||||
echo "Deploying stack $STACK"
|
||||
docker stack deploy -c "$f" "$STACK"
|
||||
done
|
||||
|
||||
deploy_compose:
|
||||
needs: detect
|
||||
# 🔑 CRITICAL FIX — do NOT run when matrix is empty
|
||||
if: ${{ contains(needs.detect.outputs.compose_matrix, '"include":[{') }}
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix: ${{ fromJSON(needs.detect.outputs.compose_matrix) }}
|
||||
|
|
@ -128,7 +132,7 @@ jobs:
|
|||
set -e
|
||||
apk add --no-cache docker-cli-compose
|
||||
|
||||
- name: Checkout repository (git clone, no node)
|
||||
- name: Checkout repository
|
||||
shell: sh
|
||||
env:
|
||||
CLONE_URL: ${{ github.server_url }}/${{ github.repository }}.git
|
||||
|
|
@ -146,7 +150,6 @@ jobs:
|
|||
run: |
|
||||
set -e
|
||||
cd repo
|
||||
echo "Validating compose file: ${{ matrix.file }}"
|
||||
docker compose -f "${{ matrix.file }}" config -q
|
||||
|
||||
- name: Deploy compose file
|
||||
|
|
@ -154,6 +157,5 @@ jobs:
|
|||
run: |
|
||||
set -e
|
||||
cd repo
|
||||
echo "Deploying compose file: ${{ matrix.file }}"
|
||||
docker compose -f "${{ matrix.file }}" pull
|
||||
docker compose -f "${{ matrix.file }}" up -d --remove-orphans
|
||||
docker c
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue