> loading_
# To create a self-updating README, create `.github/workflows/profile_updater.yml`:
#
name: Update Profile README
on:
schedule:
# Runs daily at midnight UTC
- cron: '0 0 * * *'
workflow_dispatch: # Allows manual triggering
jobs:
update-readme:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
# 1. Fetch recent content from your platforms (e.g., dev.to)
- name: Fetch latest dev.to articles
id: fetch_articles
run: |
# This script would call the dev.to API and output the titles
# For example: curl -s "https://dev.to/api/articles?username=yourusername&per_page=3"
# We'll mock the output for this example
echo "titles=My Latest Post|Another Great Article|Web3 Explained" >> $GITHUB_OUTPUT
# 2. Use an LLM to generate a summary
- name: Generate content summary with AI
id: ai_summary
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
ARTICLE_TITLES: ${{ steps.fetch_articles.outputs.titles }}
run: |
# This script calls an LLM API with a prompt
# Prompt: "Generate a markdown list summarizing these recent activities: $ARTICLE_TITLES"
# The LLM output is captured and set as a step output
SUMMARY_CONTENT="* **Blogged about:** My Latest Post\n* **Wrote:** Another Great Article\n* **Published:** Web3 Explained"
echo "summary<<EOF" >> $GITHUB_OUTPUT
echo "$SUMMARY_CONTENT" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
# 3. Inject the generated content into your README.md
- name: Update README.md
run: |
# Use a script or sed to replace content between markers
# Your README.md should have markers like this:
# <!--START_LATEST_ACTIVITY-->
# <!--END_LATEST_ACTIVITY-->
CONTENT_TO_INJECT="${{ steps.ai_summary.outputs.summary }}"
sed -i "/<!--START_LATEST_ACTIVITY-->/,/<!--END_LATEST_ACTIVITY-->/{//!d; /<!--START_LATEST_ACTIVITY-->/a\
$CONTENT_TO_INJECT
}" README.md
# 4. Commit the changes if any exist
- name: Commit and push changes
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add README.md
git diff --quiet && git diff --staged --quiet || (git commit -m "chore: auto-update profile README with latest activity" && git push)