Skip to content

Create test.yml

Create test.yml #5

Workflow file for this run

name: test
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: prepare .env
run: cp env.sample .env
- name: Build the Docker image
run: docker compose up -d
- name: Wait for HTTP 200 response
run: |
URL="https://localhost:7007"
TIMEOUT=240 # Max time to wait in seconds
SLEEP=5 # Time to wait between checks in seconds
start_time=$(date +%s)
while true; do
# Send a request to the URL and get the status code
STATUS=$(curl -o /dev/null -s -w "%{http_code}" "$URL")
# Check if the status code is 200
if [ "$STATUS" -eq 200 ]; then
echo "Success: HTTP 200 OK received from $URL"
exit 0
fi
# Check if the timeout has been exceeded
current_time=$(date +%s)
elapsed_time=$((current_time - start_time))
if [ "$elapsed_time" -ge "$TIMEOUT" ]; then
echo "Error: Timeout of $TIMEOUT seconds exceeded. Last status: $STATUS"
exit 1
fi
# Wait for a while before checking again
echo "Waiting for HTTP 200... Current status: $STATUS"
sleep "$SLEEP"
done