Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .github/actions/trigger-coolify-deploy/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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."
16 changes: 16 additions & 0 deletions .github/workflows/test-actions.yml
Original file line number Diff line number Diff line change
@@ -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