fix action 3

This commit is contained in:
pazpi 2025-12-04 22:57:49 +01:00
parent a9c48ef418
commit da18756460

View file

@ -29,10 +29,19 @@ jobs:
- name: Check for changes
id: changes
run: |
echo "DEBUG: GITHUB_OUTPUT='${GITHUB_OUTPUT:-<unset>}'"
echo "DEBUG: Checking if GITHUB_OUTPUT var is set: $(if [ -z "${GITHUB_OUTPUT+x}" ]; then echo "NOT SET"; else echo "SET (value: '$GITHUB_OUTPUT')"; fi)"
set_output() {
echo "::set-output name=$1::$2"
if [ -n "${GITHUB_OUTPUT:-}" ]; then
echo "$1=$2" >> "$GITHUB_OUTPUT"
fi
}
if git diff --quiet flake.lock; then
echo "changed=false" >> $GITHUB_OUTPUT
set_output changed false
else
echo "changed=true" >> $GITHUB_OUTPUT
set_output changed true
fi
- name: Extract LXC hosts
@ -40,6 +49,14 @@ jobs:
if: steps.changes.outputs.changed == 'true'
run: |
set -euo pipefail
set_output() {
echo "::set-output name=$1::$2"
if [ -n "${GITHUB_OUTPUT:-}" ]; then
echo "$1=$2" >> "$GITHUB_OUTPUT"
fi
}
HOSTS=$(nix eval --json .#colmena --apply 'x: builtins.filter (n: n != "meta" && builtins.elem "lxc" (x.${n}.deployment.tags or [])) (builtins.attrNames x)' 2>&1) || {
echo "Failed to evaluate colmena hosts"
exit 1
@ -47,16 +64,20 @@ jobs:
# Validate the output is a non-empty JSON array
if ! echo "$HOSTS" | jq -e '. | if type == "array" and length > 0 then true else false end' > /dev/null 2>&1; then
echo "Error: No LXC hosts found or invalid JSON output: $HOSTS"
echo "hosts=[]" >> $GITHUB_OUTPUT
set_output hosts "[]"
exit 0
fi
echo "hosts=$HOSTS" >> $GITHUB_OUTPUT
set_output hosts "$HOSTS"
echo "Discovered hosts: $HOSTS"
# Also write to file as backup (in case job outputs don't work)
echo "$HOSTS" > hosts.json
# Verify output was set
# Debug output
echo "DEBUG: GITHUB_OUTPUT exists: ${GITHUB_OUTPUT:-NOT SET}"
if [ -n "${GITHUB_OUTPUT:-}" ] && [ -f "$GITHUB_OUTPUT" ]; then
echo "DEBUG: GITHUB_OUTPUT contents:"
cat $GITHUB_OUTPUT
cat "$GITHUB_OUTPUT"
fi
- name: Debug job outputs
if: steps.changes.outputs.changed == 'true'