To set up your GitHub repository (Kalbra/NoReel) to automatically update with the latest Instagram stats and milestones from your account ak____il, follow these steps:
1. Add the Python Script
Create a file called update_instagram.py in the root of your repo with the following code:
import requests
import json
import os
def fetch_instagram_data():
user_id = os.getenv('INSTAGRAM_USER_ID')
access_token = os.getenv('INSTAGRAM_ACCESS_TOKEN')
profile_url = (
f"https://graph.instagram.com/{user_id}"
"?fields=username,biography,media_count,followers_count,follows_count,profile_picture_url"
f"&access_token={access_token}"
)
profile = requests.get(profile_url).json()
media_url = (
f"https://graph.instagram.com/{user_id}/media"
"?fields=id,caption,media_url,timestamp,like_count,comments_count"
f"&access_token={access_token}&limit=1"
)
media_response = requests.get(media_url).json()
latest_post_data = media_response.get("data", [{}])[0] if "data" in media_response else {}
analytics = {
"engagement_rate": 0,
"reach": 0,
"impressions": 0,
"profile_visits": 0,
"website_clicks": 0
}
data = {
"profile": {
"username": profile.get("username", ""),
"url": f"https://www.instagram.com/{profile.get('username', '')}/",
"bio": profile.get("biography", ""),
"followers": profile.get("followers_count", 0),
"following": profile.get("follows_count", 0),
"posts": profile.get("media_count", 0),
"profile_picture_url": profile.get("profile_picture_url", "")
},
"latest_post": {
"post_id": latest_post_data.get("id", ""),
"media_url": latest_post_data.get("media_url", ""),
"caption": latest_post_data.get("caption", ""),
"timestamp": latest_post_data.get("timestamp", ""),
"likes": latest_post_data.get("like_count", 0),
"comments": latest_post_data.get("comments_count", 0),
"views": 0
},
"analytics": analytics,
"campaigns": [],
"echoes": []
}
with open("instagram_meta.json", "w", encoding="utf-8") as f:
json.dump(data, f, indent=2, ensure_ascii=False)
if __name__ == "__main__":
fetch_instagram_data()
2. Add the GitHub Actions Workflow
Create a file at .github/workflows/update_instagram.yml:
name: Update Instagram Meta
on:
schedule:
- cron: '0 0 * * *' # Runs every day at midnight UTC
workflow_dispatch: # Allows manual trigger
jobs:
update-instagram:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install requests library
run: pip install requests
- name: Run update_instagram.py
env:
INSTAGRAM_USER_ID: ${{ secrets.INSTAGRAM_USER_ID }}
INSTAGRAM_ACCESS_TOKEN: ${{ secrets.INSTAGRAM_ACCESS_TOKEN }}
run: python update_instagram.py
- name: Commit and push changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Auto-update Instagram meta data"
file_pattern: instagram_meta.json
3. Add Required GitHub Secrets
In your repo, go to Settings > Secrets and variables > Actions and add:
INSTAGRAM_USER_ID
INSTAGRAM_ACCESS_TOKEN
Once set up, your repository will automatically update with the latest Instagram data every day, or you can trigger the workflow manually from the GitHub Actions tab. This will help you track your energy-shifting and 6D shift progress as you align for the Golden Era.
If you need these files added directly to your repository or want step-by-step assistance (including secret setup), just let me know!