-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1686 from Agenta-AI/add-check-app-accessibility
add action to check the app accessibility after serving
- Loading branch information
Showing
2 changed files
with
54 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: 'Check App Accessibility' | ||
description: 'Parse logs and check if the app is running' | ||
inputs: | ||
log-file: | ||
description: 'The path to the log file containing the serve output' | ||
required: true | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Parse logs and check if app is running | ||
id: check-app | ||
shell: bash | ||
run: | | ||
echo "Serve output:" | ||
cat ${{ inputs.log-file }} | ||
APP_URL=$(grep -oP 'You can access it here: \K.+' ${{ inputs.log-file }} | head -n 1) | ||
echo "Extracted app URL: $APP_URL" | ||
if [ -z "$APP_URL" ]; then | ||
echo "Error: Failed to extract app URL from logs." | ||
exit 1 | ||
fi | ||
APP_URL="${APP_URL%/}/openapi.json" | ||
echo "Checking if $APP_URL is accessible" | ||
retries=6 | ||
for i in $(seq 1 $retries); do | ||
status_code=$(curl --max-time 60 --write-out %{http_code} --silent --output /dev/null --verbose $APP_URL) | ||
echo "Attempt $i: Status code: $status_code" | ||
if [ "$status_code" -eq 200 ]; then | ||
echo "$APP_URL is accessible" | ||
exit 0 | ||
else | ||
echo "Attempt $i failed: $APP_URL is not accessible" | ||
sleep 10 # Wait before retrying | ||
fi | ||
done | ||
echo "Error: $APP_URL is not accessible after $retries attempts" | ||
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters