Skip to content

Update README with Our Deployments #379

Update README with Our Deployments

Update README with Our Deployments #379

Workflow file for this run

name: Update README with Our Deployments
on:
schedule:
- cron: "0 2 * * *" # Runs daily at 2 AM UTC
workflow_dispatch: # Allows manual trigger from GitHub Actions
jobs:
update-readme:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Fetch Our Domains
run: |
API_URL="https://sites.cyber32.net/api/sites"
RESPONSE=$(curl -s "$API_URL")
# Extract domains, statuses, and count
DEPLOYMENTS=$(echo "$RESPONSE" | jq -r '.[] | "\(.domain) \(.status)"')
COUNT=$(echo "$DEPLOYMENTS" | wc -l)
# Get current time in Asia/Dhaka timezone
LAST_UPDATED=$(TZ=Asia/Dhaka date +"%Y-%m-%d %H:%M:%S Asia/Dhaka")
if [ -z "$RESPONSE" ] || [ "$RESPONSE" == "[]" ]; then
echo "No domains found. Exiting."
exit 1
fi
echo "## Our Deployments" >> domains.md
echo "This platform is managing 🔥 \$\${\color{red}$COUNT}\$\$ 🔥 websites" >> domains.md
echo "" >> domains.md
echo "_Last updated: **$LAST_UPDATED**_" >> domains.md
echo "" >> domains.md
echo "| # | Domain | Status |" >> domains.md
echo "|---|--------|--------|" >> domains.md
i=1
while read -r domain status; do
echo "| $i | [$domain](http://$domain) | $status |" >> domains.md
i=$((i + 1))
done <<< "$DEPLOYMENTS"
- name: Update README.md
run: |
awk '/## Our Deployments/{flag=1; next} /##/{flag=0} !flag' README.md > temp.md
cat temp.md domains.md > README.md
rm temp.md domains.md
- name: Commit and Push Changes
run: |
git config --global user.name "github-actions"
git config --global user.email "actions@github.com"
git add README.md
git commit -m "Auto-update Deployments List - $(date +'%Y-%m-%d')" || exit 0
git push