mirror of
https://github.com/aliasvault/aliasvault.git
synced 2026-01-31 09:22:25 -05:00
104 lines
3.2 KiB
YAML
104 lines
3.2 KiB
YAML
name: Docker Compose Build
|
|
|
|
on:
|
|
push:
|
|
branches: [ "main" ]
|
|
pull_request:
|
|
branches: [ "main" ]
|
|
|
|
jobs:
|
|
test-docker:
|
|
runs-on: ubuntu-latest
|
|
|
|
services:
|
|
docker:
|
|
image: docker:26.0.0
|
|
options: --privileged
|
|
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- name: Create .env file with custom SMTP port as port 25 is not allowed in GitHub Actions
|
|
run: |
|
|
echo "SMTP_PORT=2525" > .env
|
|
|
|
- name: Set permissions and run install.sh
|
|
run: |
|
|
chmod +x install.sh
|
|
./install.sh build --verbose
|
|
|
|
- name: Test if services are responding
|
|
uses: nick-fields/retry@v3
|
|
with:
|
|
timeout_minutes: 5
|
|
max_attempts: 5
|
|
command: |
|
|
sleep 15
|
|
|
|
# Array of endpoints to test
|
|
declare -A endpoints=(
|
|
["WASM"]="https://localhost:443"
|
|
["WebApi"]="https://localhost:443/api"
|
|
["Admin"]="https://localhost:443/admin/user/login"
|
|
)
|
|
|
|
failed=false
|
|
|
|
# Test HTTP endpoints
|
|
for name in "${!endpoints[@]}"; do
|
|
url="${endpoints[$name]}"
|
|
echo "Testing $name at $url"
|
|
|
|
# Store both response body and HTTP code
|
|
response=$(curl -k -s -w "\nHTTP_CODE=%{http_code}" "$url")
|
|
http_code=$(echo "$response" | grep "HTTP_CODE=" | cut -d= -f2)
|
|
body=$(echo "$response" | sed '$d') # Remove the last line (HTTP_CODE)
|
|
|
|
if [ "$http_code" -ne 200 ]; then
|
|
echo "❌ $name failed with HTTP $http_code at $url"
|
|
echo "Response body:"
|
|
echo "$body"
|
|
failed=true
|
|
else
|
|
echo "✅ $name responded with HTTP 200"
|
|
fi
|
|
done
|
|
|
|
# Test SMTP
|
|
echo "Testing SmtpService at localhost:2525"
|
|
if ! nc -zv localhost 2525 2>&1 | grep -q 'succeeded'; then
|
|
echo "❌ SmtpService failed to respond on port 2525"
|
|
failed=true
|
|
else
|
|
echo "✅ SmtpService responded successfully"
|
|
fi
|
|
|
|
# Exit with error if any service failed
|
|
if [ "$failed" = true ]; then
|
|
# Get container logs
|
|
echo "Container Logs admin:"
|
|
docker compose logs admin
|
|
echo "Container Logs api:"
|
|
docker compose logs api
|
|
echo "Container Logs client:"
|
|
docker compose logs client
|
|
echo "Container Logs smtp:"
|
|
docker compose logs smtp
|
|
echo "Container Logs reverse-proxy:"
|
|
docker compose logs reverse-proxy
|
|
|
|
# Restart containers for next test in case of failure
|
|
docker compose restart
|
|
exit 1
|
|
fi
|
|
|
|
- name: Test install.sh reset-password output
|
|
run: |
|
|
output=$(./install.sh reset-password)
|
|
if ! echo "$output" | grep -E '.*New admin password: [A-Za-z0-9+/=]{8,}.*'; then
|
|
echo "Password reset output format is incorrect"
|
|
echo "Expected: 'New admin password: <at least 8 base64 chars>'"
|
|
echo "Actual: $output"
|
|
exit 1
|
|
fi
|