-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (48 loc) · 1.98 KB
/
update-readme.yml
File metadata and controls
58 lines (48 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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