Mirror OSP → GitLab #147
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Mirror OSP → GitLab | |
| # Mirrors every repo in OpenOS-Project-OSP to its GitLab counterpart under | |
| # openos-project, creating the GitLab project if it doesn't exist yet. | |
| # GitLab-only branches (all-features, feat/*, lts, openos/ci) are preserved | |
| # because pushes are selective — no --mirror prune. | |
| on: | |
| schedule: | |
| - cron: '30 * * * *' # Hourly at :30 | |
| workflow_run: | |
| workflows: | |
| - "Add Mirror Repo" | |
| types: [completed] | |
| workflow_dispatch: | |
| inputs: | |
| repo_filter: | |
| description: "Repo name substring filter (blank = all)" | |
| required: false | |
| default: "" | |
| dry_run: | |
| description: "Dry run — skip git push and GitLab project creation" | |
| type: boolean | |
| required: false | |
| default: false | |
| subgroup_filter: | |
| description: "Limit to a specific GitLab subgroup" | |
| type: choice | |
| required: false | |
| default: "all" | |
| options: | |
| - all | |
| - neon-deving | |
| - core | |
| - desktop | |
| - tools | |
| - infra | |
| - mirrors | |
| - ops | |
| rate_limit_rerun: | |
| description: "Set by rate-limit-rerun workflow — prevents re-trigger loops" | |
| required: false | |
| default: "false" | |
| type: string | |
| concurrency: | |
| group: mirror-osp-to-gitlab | |
| cancel-in-progress: false # Never cancel mid-mirror — let it finish | |
| permissions: | |
| contents: read | |
| # ── Rate limits ────────────────────────────────────────────────────────────── | |
| # GitHub REST API (SYNC_TOKEN): 5 000 req/hr — used to list OSP repos. | |
| # gh_api_list() retries HTTP 403/429 with X-RateLimit-Reset sleep. | |
| # GitLab REST API (GITLAB_SYNC_TOKEN): 2 000 req/min per token. | |
| # gl_api() retries HTTP 429/403 with RateLimit-Reset sleep (up to 3 times). | |
| # git push to GitLab: git_push_retry() retries up to 3 times with linear | |
| # backoff (15 s, 30 s, 45 s) on any push failure. | |
| # If GITLAB_SYNC_TOKEN is unset the script exits 0 (skip) — no CI failure | |
| # notification is generated. | |
| jobs: | |
| mirror: | |
| if: inputs.rate_limit_rerun != 'true' | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 60 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Quota pre-flight | |
| id: quota | |
| env: | |
| GH_TOKEN: ${{ secrets.SYNC_TOKEN }} | |
| MIN_QUOTA: "1500" | |
| run: | | |
| remaining=$(curl -sf \ | |
| -H "Authorization: token ${GH_TOKEN}" \ | |
| -H "Accept: application/vnd.github+json" \ | |
| https://api.github.com/rate_limit \ | |
| | python3 -c "import sys,json; print(json.load(sys.stdin)['resources']['core']['remaining'])") | |
| echo "remaining=${remaining}" >> "$GITHUB_OUTPUT" | |
| if [[ "${remaining}" -lt "${MIN_QUOTA}" ]]; then | |
| echo "skip=true" >> "$GITHUB_OUTPUT" | |
| echo "Quota too low (${remaining} < ${MIN_QUOTA}) — skipping. quota-monitor will retry." | |
| else | |
| echo "skip=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Mirror OSP repos to GitLab | |
| if: steps.quota.outputs.skip == 'false' | |
| env: | |
| GH_TOKEN: ${{ secrets.SYNC_TOKEN }} | |
| GITLAB_TOKEN: ${{ secrets.GITLAB_SYNC_TOKEN }} | |
| OSP_ORG: OpenOS-Project-OSP | |
| BUDGET_MINUTES: "55" | |
| run: bash scripts/mirror-osp-to-gitlab.sh |