deploy
Some checks failed
Deploy on push / detect (push) Failing after 1s
Deploy on push / deploy_swarm (push) Has been skipped
Deploy on push / deploy_compose (push) Has been cancelled

This commit is contained in:
traveler 2026-01-12 20:58:44 -06:00
parent 7c6f381c4d
commit 52773b7f5e

View file

@ -17,7 +17,7 @@ jobs:
set -euo pipefail set -euo pipefail
git config --global --add safe.directory "$PWD" git config --global --add safe.directory "$PWD"
git fetch origin git fetch origin
git checkout "$GITHUB_REF_NAME" git checkout -B "$GITHUB_REF_NAME" "origin/$GITHUB_REF_NAME"
- name: Detect changed YAML files - name: Detect changed YAML files
id: changes id: changes
@ -28,12 +28,11 @@ jobs:
BASE="${{ github.event.before }}" BASE="${{ github.event.before }}"
HEAD="${{ github.sha }}" HEAD="${{ github.sha }}"
# Handle edge cases (new branch / forced push etc.) if [ -z "$BASE" ] || [ "$BASE" = "0000000000000000000000000000000000000000" ]; then
if [ -z "${BASE}" ] || [ "${BASE}" = "0000000000000000000000000000000000000000" ]; then
BASE="$(git rev-parse "${HEAD}~1" || true)" BASE="$(git rev-parse "${HEAD}~1" || true)"
fi fi
if [ -z "${BASE}" ]; then if [ -z "$BASE" ]; then
echo "No base commit found; deploying nothing." echo "No base commit found; deploying nothing."
echo "swarm_files=" >> "$GITHUB_OUTPUT" echo "swarm_files=" >> "$GITHUB_OUTPUT"
echo 'compose_matrix={"include":[]}' >> "$GITHUB_OUTPUT" echo 'compose_matrix={"include":[]}' >> "$GITHUB_OUTPUT"
@ -44,23 +43,13 @@ jobs:
echo "Changed files:" echo "Changed files:"
echo "$CHANGED" echo "$CHANGED"
# --------------------
# Swarm stack YAMLs # Swarm stack YAMLs
# --------------------
SWARM_FILES="$(echo "$CHANGED" | grep -E '^services/swarm/stacks/.*\.ya?ml$' || true)" SWARM_FILES="$(echo "$CHANGED" | grep -E '^services/swarm/stacks/.*\.ya?ml$' || true)"
echo "Swarm stack files:"
echo "$SWARM_FILES"
echo "swarm_files=$(echo "$SWARM_FILES" | xargs)" >> "$GITHUB_OUTPUT" echo "swarm_files=$(echo "$SWARM_FILES" | xargs)" >> "$GITHUB_OUTPUT"
# -------------------- # Compose YAMLs: services/compose/<host>/<service>/<file>.yml
# Compose YAMLs
# services/compose/<host>/<service>/<file>.yml
# --------------------
COMPOSE_FILES="$(echo "$CHANGED" | grep -E '^services/compose/[^/]+/[^/]+/.*\.ya?ml$' || true)" COMPOSE_FILES="$(echo "$CHANGED" | grep -E '^services/compose/[^/]+/[^/]+/.*\.ya?ml$' || true)"
echo "Compose files:"
echo "$COMPOSE_FILES"
# Build matrix items: {"host":"nas","file":"services/compose/nas/foo/comixed.yaml"}
JSON='{"include":[' JSON='{"include":['
FIRST=1 FIRST=1
while read -r FILE; do while read -r FILE; do
@ -73,8 +62,6 @@ jobs:
JSON+=']}' JSON+=']}'
echo "compose_matrix=$JSON" >> "$GITHUB_OUTPUT" echo "compose_matrix=$JSON" >> "$GITHUB_OUTPUT"
echo "Compose matrix:"
echo "$JSON"
deploy_swarm: deploy_swarm:
needs: detect needs: detect
@ -87,14 +74,13 @@ jobs:
set -euo pipefail set -euo pipefail
git config --global --add safe.directory "$PWD" git config --global --add safe.directory "$PWD"
git fetch origin git fetch origin
git checkout "$GITHUB_REF_NAME" git checkout -B "$GITHUB_REF_NAME" "origin/$GITHUB_REF_NAME"
- name: Validate swarm stacks - name: Validate swarm stacks
shell: bash shell: bash
run: | run: |
set -euo pipefail set -euo pipefail
for f in ${{ needs.detect.outputs.swarm_files }}; do for f in ${{ needs.detect.outputs.swarm_files }}; do
echo "Validating swarm stack file: $f"
docker stack config -c "$f" >/dev/null docker stack config -c "$f" >/dev/null
done done
@ -104,7 +90,6 @@ jobs:
set -euo pipefail set -euo pipefail
for f in ${{ needs.detect.outputs.swarm_files }}; do for f in ${{ needs.detect.outputs.swarm_files }}; do
STACK="$(basename "$f" | sed 's/\.ya\?ml$//')" STACK="$(basename "$f" | sed 's/\.ya\?ml$//')"
echo "Deploying swarm stack: $STACK from $f"
docker stack deploy -c "$f" "$STACK" docker stack deploy -c "$f" "$STACK"
done done
@ -122,21 +107,17 @@ jobs:
set -euo pipefail set -euo pipefail
git config --global --add safe.directory "$PWD" git config --global --add safe.directory "$PWD"
git fetch origin git fetch origin
git checkout "$GITHUB_REF_NAME" git checkout -B "$GITHUB_REF_NAME" "origin/$GITHUB_REF_NAME"
- name: Validate compose file - name: Validate compose file
shell: bash shell: bash
run: | run: |
set -euo pipefail set -euo pipefail
F="${{ matrix.file }}" docker compose -f "${{ matrix.file }}" config -q
echo "Validating compose file: $F"
docker compose -f "$F" config -q
- name: Deploy compose file - name: Deploy compose file
shell: bash shell: bash
run: | run: |
set -euo pipefail set -euo pipefail
F="${{ matrix.file }}" docker compose -f "${{ matrix.file }}" pull
echo "Deploying compose file: $F" docker compose -f "${{ matrix.file }}" up -d --remove-orphans
docker compose -f "$F" pull
docker compose -f "$F" up -d --remove-orphans