Keep Server Awake #2498
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
name: Keep Server Awake | |
on: | |
schedule: | |
# Run every 10 minutes | |
- cron: '*/10 * * * *' | |
# Allow manual triggering | |
workflow_dispatch: | |
jobs: | |
cron: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Ping Backend server to keep it awake | |
run: | | |
# Timeout after 10 seconds, retry up to 3 times | |
response=$(curl -L -s -o /dev/null -w "%{http_code}" \ | |
--connect-timeout 10 \ | |
--max-time 20 \ | |
--retry 3 \ | |
--retry-delay 5 \ | |
--retry-max-time 60 \ | |
"${{ secrets.WEBSITE_URL }}") | |
if [ $response -eq 200 ]; then | |
echo "Successfully pinged website. Status: $response" | |
exit 0 | |
else | |
echo "Failed to ping website. Status: $response" | |
exit 1 | |
fi |