-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (139 loc) · 5.73 KB
/
Copy pathupdate-readmes.yml
File metadata and controls
147 lines (139 loc) · 5.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: Update READMEs
# Updates AI-owned sections (<!-- AI:start:* --> blocks) in existing READMEs
# and refreshes repo descriptions + topics across Interested-Deving-1896.
#
# Priority tiers:
# 1. Repos mirrored into OSP (fetched live from Interested-Deving-1896 org)
# 2. All remaining repos in Interested-Deving-1896 (full sweep only)
#
# Triggers:
# - Add Mirror Repo completes → priority-only run for the new repo
# - Other content workflows complete → priority-only run
# - Daily 03:00 UTC → full sweep (priority first, then secondary)
# - Push to a repo → process that repo only
# - Manual dispatch → configurable
on:
push:
branches: ['**']
paths-ignore:
- '.github/workflows/**'
- 'scripts/**'
- 'registered-imports.json'
- 'README.md'
- '.gitignore'
- '.devcontainer/**'
schedule:
- cron: '0 3 * * *' # Full sweep daily at 03:00 UTC (off-peak)
workflow_run:
workflows:
- "Add Mirror Repo"
- "Import Repository"
- "Clone Org"
- "Merge Repos into Monorepo"
- "Sync All Forks"
- "Sync Registered Imports"
- "Sync from GitLab"
- "Sync Interested-Deving-1896 Forks"
- "Sync Upstream Sources"
- "Sync penguins-eggs docs to penguins-eggs-book"
types: [completed]
workflow_dispatch:
inputs:
repos:
description: 'Space-separated repo names to process (leave blank for all)'
required: false
type: string
default: ''
priority_only:
description: 'Process OSP-mirrored repos only (faster, lower API usage)'
type: boolean
required: false
default: false
dry_run:
description: 'Dry run — detect stale sections without writing changes'
type: boolean
required: false
default: false
force_rewrite:
description: 'Strip <!-- AI:skip --> and migrate all static READMEs to the marker template'
type: boolean
required: false
default: false
rate_limit_rerun:
description: "Set by rate-limit-rerun workflow — prevents re-trigger loops"
required: false
default: "false"
type: string
concurrency:
group: update-readmes
cancel-in-progress: true # Newer push supersedes older one
permissions:
contents: write
# ── Rate limits ──────────────────────────────────────────────────────────────
# GitHub REST API (SYNC_TOKEN): 5 000 req/hr — reads/writes repo files.
# Retries HTTP 403/429 with X-RateLimit-Reset sleep (up to 3 attempts).
# GitHub Models API (SYNC_TOKEN): quota varies; gpt-4o-mini is used.
# HTTP 429 includes Retry-After. The script retries up to 3 times and
# skips AI generation (exits 0) if the quota is fully exhausted.
jobs:
update:
runs-on: ubuntu-latest
timeout-minutes: 60
# Only run on pushes from Interested-Deving-1896 itself, not mirror bots.
# workflow_run and schedule always run (they originate from this repo).
if: github.event_name != 'push' || github.repository_owner == 'Interested-Deving-1896'
steps:
- uses: actions/checkout@v6
- name: Determine repos to process
id: repos
run: |
if [[ "${{ github.event_name }}" == "push" ]]; then
echo "changed_repos=${{ github.event.repository.name }}" >> "$GITHUB_OUTPUT"
echo "priority_only=false" >> "$GITHUB_OUTPUT"
echo "new_repo=" >> "$GITHUB_OUTPUT"
elif [[ "${{ github.event_name }}" == "workflow_run" ]]; then
triggering="${{ github.event.workflow.name }}"
if [[ "$triggering" == "Add Mirror Repo" ]]; then
# Extract the repo name from the triggering run's inputs via API.
run_id="${{ github.event.workflow_run.id }}"
new_repo=$(gh api "repos/${{ github.repository }}/actions/runs/${run_id}" \
| jq -r '.inputs.repo_url // empty' \
| sed 's|.*/||')
echo "new_repo=${new_repo}" >> "$GITHUB_OUTPUT"
echo "changed_repos=" >> "$GITHUB_OUTPUT"
echo "priority_only=true" >> "$GITHUB_OUTPUT"
else
# Other workflow_run triggers: priority-only sweep.
echo "new_repo=" >> "$GITHUB_OUTPUT"
echo "changed_repos=" >> "$GITHUB_OUTPUT"
echo "priority_only=true" >> "$GITHUB_OUTPUT"
fi
elif [[ -n "${{ inputs.repos }}" ]]; then
echo "changed_repos=${{ inputs.repos }}" >> "$GITHUB_OUTPUT"
echo "priority_only=false" >> "$GITHUB_OUTPUT"
echo "new_repo=" >> "$GITHUB_OUTPUT"
else
# Manual dispatch or schedule: respect priority_only input;
# schedule always does a full sweep.
echo "changed_repos=" >> "$GITHUB_OUTPUT"
echo "priority_only=${{ inputs.priority_only || 'false' }}" >> "$GITHUB_OUTPUT"
echo "new_repo=" >> "$GITHUB_OUTPUT"
fi
env:
GH_TOKEN: ${{ secrets.SYNC_TOKEN }}
- name: Update READMEs
env:
GH_TOKEN: ${{ secrets.SYNC_TOKEN }}
GITHUB_OWNER: Interested-Deving-1896
CHANGED_REPOS: ${{ steps.repos.outputs.changed_repos }}
NEW_REPO: ${{ steps.repos.outputs.new_repo }}
PRIORITY_ONLY: ${{ steps.repos.outputs.priority_only }}
DRY_RUN: ${{ inputs.dry_run || 'false' }}
FORCE_REWRITE: ${{ inputs.force_rewrite || 'false' }}
run: bash scripts/update-readmes.sh
- name: Write summary
if: always()
env:
JOB_STATUS: ${{ job.status }}
INPUTS_JSON: ${{ toJSON(inputs) }}
run: bash scripts/write-summary.sh