Skip to content

GitHub Follower Bot #69

GitHub Follower Bot

GitHub Follower Bot #69

name: GitHub Follower Bot
on:
schedule:
- cron: '0 23 * * *' # Runs once a day
workflow_dispatch:
permissions:
contents: write # Needed for committing and pushing changes
actions: read
packages: write
defaults:
run:
working-directory: ./github-followers
jobs:
follow-bot:
runs-on: ubuntu-latest
env:
GITHUB_USER: trcjr
PERSONAL_GITHUB_TOKEN: ${{ secrets.PERSONAL_GITHUB_TOKEN }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.8' # Consider updating to a newer version if possible
- name: Upgrade pip
run: python -m pip install --upgrade pip
- name: Install Pipenv
run: pip install pipenv
- name: Cache Pipenv dependencies
uses: actions/cache@v4
with:
path: |
~/.local/share/pipenv
~/.cache/pip
~/.venv
key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }}
restore-keys: |
${{ runner.os }}-pipenv-
- name: Install dependencies
run: pipenv install --deploy --ignore-pipfile
- name: Verify Pipenv Installation
run: pipenv --version
- name: List Installed Packages
run: pipenv run pip list
- name: Run Follower Bot
env:
GITHUB_USER: ${{ env.GITHUB_USER }}
PERSONAL_GITHUB_TOKEN: ${{ env.PERSONAL_GITHUB_TOKEN }}
run: pipenv run python github_follow_followers.py
- name: Commit and Push Changes
if: github.ref == 'refs/heads/main' # Ensures it runs only on the main branch
run: |
git config user.name "GitHub Follower Bot"
git config user.email "[email protected]"
git add -A
timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
git commit -m "Automated Commit: ${timestamp} (UTC)" || echo "No changes to commit."
git push origin main