Skip to content

This project provides a simple way to track visits to your GitHub repository using a dynamic badge. Integrate this badge into your README.md file to display visit counts and engage with your audience. πŸš€ It works every 5 minutes

Notifications You must be signed in to change notification settings

Armanx200/visitor-badge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Visitor Badge Installation Guide πŸš€

Visits

Welcome to the visitor-badge repository by Arman Kianian! This guide will help you set up and use the visitor badge to track visits to your GitHub repository. Let's get started! πŸŽ‰

Prerequisites πŸ“‹

Before you begin, make sure you have:

  • A GitHub account
  • A repository where you want to add the visitor badge
  • Basic knowledge of Git and GitHub

Step-by-Step Installation πŸ› οΈ

1. Fork the Repository 🍴

First, fork the visitor-badge repository to your GitHub account.

2. Clone the Repository πŸ“‚

Next, clone the forked repository to your local machine:

git clone https://github.com/<your-username>/visitor-badge.git
cd visitor-badge

3. Set Up the Visit Counter πŸš₯

Ensure you have a visits.txt file in the root of your repository to track the visit count. If it doesn't exist, create it:

echo "0" > visits.txt

4. Add the Badge to Your README.md πŸ“

Update your README.md file to include the visit badge. Add the following line where you want the badge to appear:

![Visits](https://img.shields.io/badge/Visits-15850-blue)

5. Set Up GitHub Actions βš™οΈ

Create a workflow file to automate visit count updates. Create a directory .github/workflows in your repository if it doesn't already exist, then create a file named update-visits.yml:

name: Update Visits

on:
  push:
    branches:
      - main
  schedule:
    - cron: '*/15 * * * *' # Runs every 15 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-15850-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

6. Commit and Push Your Changes πŸš€

Commit and push the changes to your GitHub repository:

git add visits.txt README.md .github/workflows/update-visits.yml
git commit -m "Set up visit tracking workflow"
git push origin main

7. Monitor Your Visits πŸ“Š

Once everything is set up, your visit count will be updated automatically every 15 minutes. You can view the visit badge in your README.md:

Visits

Congratulations! πŸŽ‰

You have successfully set up the visitor badge in your repository! Now you can track how many people visit your GitHub project. Happy coding! πŸ’»

About

This project provides a simple way to track visits to your GitHub repository using a dynamic badge. Integrate this badge into your README.md file to display visit counts and engage with your audience. πŸš€ It works every 5 minutes

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published