Skip to content

Commit

Permalink
Create update-visits.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
shxntanu authored Jan 4, 2025
1 parent a73f137 commit 69309a1
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/update-visits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Update Visits

on:
push:
branches:
- main
schedule:
- cron: '*/5 * * * *' # Runs every 5 minutes

jobs:
update-visits:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Increment visit counter
id: increment
run: |
if [ ! -f visits.txt ]; then echo "0" > visits.txt; fi
visits=$(cat visits.txt)
visits=$((visits + 1))
echo $visits > visits.txt
echo "::set-output name=visits::$visits"
- name: Update README.md
run: |
visits=${{ steps.increment.outputs.visits }}
badge="![Visits](https://img.shields.io/badge/Visits-$visits-blue)"
sed -i 's|!\[Visits\](https://img.shields.io/badge/Visits-.*-blue)|'"$badge"'|' README.md
- name: Commit changes
run: |
git config --global user.name 'github-actions'
git config --global user.email 'github-actions@github.com'
git add visits.txt README.md
git commit -m 'Update visits count'
git push

0 comments on commit 69309a1

Please sign in to comment.