diff --git a/.github/actions/trigger-coolify-deploy/action.yml b/.github/actions/trigger-coolify-deploy/action.yml index 969d7e4..596bcb0 100644 --- a/.github/actions/trigger-coolify-deploy/action.yml +++ b/.github/actions/trigger-coolify-deploy/action.yml @@ -182,11 +182,13 @@ runs: phantom_uuid=$(printf '%s' "$phantom" | jq -r '.deployment_uuid') phantom_status=$(printf '%s' "$phantom" | jq -r '.status') - # deployment_uuid comes from the Coolify API response — validate its shape + # phantom_uuid comes from the Coolify API response — validate its shape # before using it in a URL or SSH command, in case Coolify ever returns - # something malformed. - if ! printf '%s' "$phantom_uuid" | grep -qiE '^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$'; then - echo " WARNING: unexpected deployment_uuid format '${phantom_uuid}', skipping" + # something malformed. Accepts both the legacy UUID format and Coolify's + # newer nanoid-style ids (e.g. j9rlp1cg3qdsuqi8sqsvykpo). Uses a bash regex + # match (not grep) so ^...$ anchors the whole string, not per-line. + if ! [[ "$phantom_uuid" =~ ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}|[0-9a-z]{20,30})$ ]]; then + echo " WARNING: unexpected phantom_uuid format '${phantom_uuid}', skipping" continue fi diff --git a/.github/actions/trigger-coolify-deploy/tests/deployment_uuid_format.sh b/.github/actions/trigger-coolify-deploy/tests/deployment_uuid_format.sh new file mode 100755 index 0000000..f4ee2fd --- /dev/null +++ b/.github/actions/trigger-coolify-deploy/tests/deployment_uuid_format.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +# Regression test for the deployment_uuid/phantom_uuid format check in action.yml +# (cancel_phantom_builds). Keeps this in sync with the regex at that call site — +# if you change one, change both. +set -euo pipefail + +PATTERN='^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}|[0-9a-z]{20,30})$' + +check() { + local value="$1" expect="$2" label="$3" actual + if [[ "$value" =~ $PATTERN ]]; then + actual=accept + else + actual=reject + fi + if [ "$actual" != "$expect" ]; then + echo "FAIL: $label — expected $expect, got $actual for '${value}'" + exit 1 + fi + echo "ok: $label" +} + +check "a1b2c3d4-e5f6-7890-abcd-ef1234567890" accept "legacy UUID" +check "A1B2C3D4-E5F6-7890-ABCD-EF1234567890" accept "legacy UUID, uppercase" +check "j9rlp1cg3qdsuqi8sqsvykpo" accept "Coolify nanoid-style id (24 chars)" +check "abcdefghijklmnopqrst" accept "nanoid-style id, 20 chars (lower bound)" +check "abcdefghijklmnopqrstuvwxyzabcd" accept "nanoid-style id, 30 chars (upper bound)" +check "not a valid id!" reject "garbage with spaces/punctuation" +check "" reject "empty string" +check "abc123" reject "too short to be a nanoid" +check "abcdefghijklmnopqrstuvwxyzabcde" reject "31 chars, over the bound" + +echo "All deployment_uuid format checks passed." diff --git a/.github/workflows/test-actions.yml b/.github/workflows/test-actions.yml new file mode 100644 index 0000000..b143500 --- /dev/null +++ b/.github/workflows/test-actions.yml @@ -0,0 +1,16 @@ +name: Test actions + +on: + push: + branches: [main, master] + pull_request: + +jobs: + trigger-coolify-deploy-tests: + name: trigger-coolify-deploy shell tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + + - name: Run deployment_uuid format tests + run: bash .github/actions/trigger-coolify-deploy/tests/deployment_uuid_format.sh