Skip to content

Generate Starred Repos Report #91

Generate Starred Repos Report

Generate Starred Repos Report #91

name: Generate Starred Repos Report
on:
schedule:
- cron: '30 22 * * *' # Run daily at 6:30am UTC+8
workflow_dispatch: # Allow manual trigger
# push:
# branches:
# - master
jobs:
generate-report:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.RELEASE_TOKEN }}
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"
- name: Install dependencies
run: |
uv sync --all-extras --dev
- name: Restore commit timestamps cache
uses: actions/cache/restore@v4
with:
path: commit_timestamps.json
key: commit-timestamps-${{ github.run_id }}
restore-keys: |
commit-timestamps-
- name: Restore report cache
uses: actions/cache/restore@v4
with:
path: reports/
key: report-cache-${{ github.run_id }}
restore-keys: |
report-cache-
- name: Set TODAY variable
id: set_date
run: |
echo "TODAY=$(TZ=Asia/Shanghai date +'%Y-%m-%d')" >> $GITHUB_ENV
echo "TODAY=$(TZ=Asia/Shanghai date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Generate report
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
DEEPSEEK_API_KEY: ${{ secrets.DEEPSEEK_API_KEY }}
REPO_LIMIT: ${{ vars.REPO_LIMIT }}
EMPTY_REPO_CONSECUTIVE_LIMIT: ${{ vars.EMPTY_REPO_CONSECUTIVE_LIMIT }}
run: uv run src/main.py
id: generate_report
- name: Save commit timestamps cache
uses: actions/cache/save@v4
with:
path: commit_timestamps.json
key: commit-timestamps-${{ github.run_id }}
- name: Save report cache
uses: actions/cache/save@v4
with:
path: reports/
key: report-cache-${{ github.run_id }}
- name: Create Release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
with:
name: "Activity Report ${{ env.TODAY }}"
tag_name: ${{ env.TODAY }}
body_path: ${{ steps.generate_report.outputs.report_file }}
files: |
${{ steps.generate_report.outputs.report_file }}
${{ steps.generate_report.outputs.report_json_file }}
reports/feed.json
- name: Create latest symbolic links
run: |
cp ${{ steps.generate_report.outputs.report_json_file }} reports/recent_commits_latest.json
cp ${{ steps.generate_report.outputs.report_file }} reports/recent_commits_latest.md
- name: Copy latest reports to docs
run: |
cp reports/recent_commits_latest.json docs/recent_commits_latest.json
cp reports/recent_commits_latest.md docs/recent_commits_latest.md
- name: Upload latest reports
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
with:
tag_name: latest
files: |
reports/recent_commits_latest.json
reports/recent_commits_latest.md
reports/feed.json
prerelease: true
- name: Force update pages branch
run: |
git branch -D pages || true
git checkout -b pages
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add docs/recent_commits_latest.json docs/recent_commits_latest.md
git commit -m "Update reports for ${{ env.TODAY }}" || exit 0
git push origin pages --force