Check URL Status #34
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: Check URL Status | |
on: | |
schedule: | |
- cron: "*/15 * * * *" # Every 15 minutes | |
workflow_dispatch: # Allow manual triggering | |
jobs: | |
check-status: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Check Website Status | |
run: | | |
STATUS_CODE=$(curl -o /dev/null -s -w "%{http_code}" https://procryptoflashers.vercel.app/) | |
CURRENT_TIME=$(date -u +"%Y-%m-%d %H:%M:%S UTC") | |
if [ "$STATUS_CODE" -eq 200 ]; then | |
echo "Website is up! Status Code: 200" | |
echo "Status: 200 OK" > last_check.txt | |
echo "Check Time: $CURRENT_TIME" >> last_check.txt | |
else | |
echo "Website is down. Status Code: $STATUS_CODE" | |
echo "Status: Down" > last_check.txt | |
echo "Check Time: $CURRENT_TIME" >> last_check.txt | |
fi | |
- name: Update README.md with Last Check Status | |
run: | | |
LAST_CHECK_CONTENT=$(cat last_check.txt) | |
sed -i "s|Last Check: .*|Last Check: ![Status Badge](https://img.shields.io/badge/status-200%20OK-green)|" README.md | |
sed -i "s|Check Time: .*|Check Time: $CURRENT_TIME|" README.md | |
git add README.md | |
git commit -m "Update Last Check Status in README.md" | |
git push | |
- name: Commit and Push Status Update | |
run: | | |
git config --global user.name "github-actions" | |
git config --global user.email "github-actions@github.com" | |
git add last_check.txt | |
git commit -m "Update website status" | |
git push |