Skip to content

Create main.yml

Create main.yml #1

Workflow file for this run

name: Monitor GitHub Followers
on:
schedule:
- cron: '0 */6 * * *' # Every 6 hours
workflow_dispatch: # Manual trigger
push:
branches: [ main ]
permissions:
contents: write
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
monitor-followers:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Monitor followers and update data
env:
TOKEN: ${{ secrets.TOKEN }}
GITHUB_USERNAME: ${{ github.repository_owner }}
run: |
node scripts/monitor.js
- name: Commit and push changes
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add data/
if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "Update follower data - $(date)"
git push
fi
deploy:
needs: monitor-followers
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: main
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: './dashboard'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4