mirror of
https://github.com/gmh5225/awesome-game-security
synced 2026-06-21 13:56:22 +00:00
109 lines
3.9 KiB
YAML
109 lines
3.9 KiB
YAML
name: Archive Repos
|
|
|
|
on:
|
|
# push:
|
|
# branches:
|
|
# - main
|
|
# schedule:
|
|
# # Run every day at 03:00 UTC (11:00 Beijing)
|
|
# - cron: "0 3 * * *"
|
|
workflow_dispatch:
|
|
inputs:
|
|
workers:
|
|
description: "Concurrent clone workers"
|
|
required: false
|
|
default: "3"
|
|
commit_every:
|
|
description: "Commit & push every N successful archives"
|
|
required: false
|
|
default: "1"
|
|
owner_filter:
|
|
description: "Only archive repos from this owner (leave empty for all)"
|
|
required: false
|
|
default: ""
|
|
limit:
|
|
description: "Max repos to process this run (0 = all pending)"
|
|
required: false
|
|
default: "0"
|
|
skip_existing:
|
|
description: "Skip repos that are already archived (default: true)"
|
|
type: boolean
|
|
required: false
|
|
default: true
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
archive:
|
|
runs-on: ubuntu-latest
|
|
# GitHub Actions hard limit is 6h; set slightly under to allow clean teardown
|
|
timeout-minutes: 350
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
# Need full history so we can push back
|
|
fetch-depth: 0
|
|
|
|
# ── download pre-built code2prompt binary ─────────────────────────────
|
|
- name: Install code2prompt
|
|
run: |
|
|
curl -fsSL -o /usr/local/bin/code2prompt \
|
|
https://github.com/mufeedvh/code2prompt/releases/download/v4.2.0/code2prompt-x86_64-unknown-linux-gnu
|
|
chmod +x /usr/local/bin/code2prompt
|
|
|
|
# ── git identity for auto-commits ─────────────────────────────────────
|
|
- name: Configure git
|
|
run: |
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
# Large archive files can exceed the default 1 MB HTTP send buffer,
|
|
# causing HTTP 408 / RPC failures on push.
|
|
git config http.postBuffer 524288000
|
|
git config http.lowSpeedLimit 0
|
|
git config http.lowSpeedTime 999999
|
|
|
|
# ── run the archiver ───────────────────────────────────────────────────
|
|
- name: Archive repos
|
|
env:
|
|
REPO_SNAPSHOT_HOST: ${{ secrets.REPO_SNAPSHOT_HOST }}
|
|
run: |
|
|
ARGS=""
|
|
ARGS="$ARGS --workers ${{ github.event.inputs.workers || '3' }}"
|
|
ARGS="$ARGS --commit-every ${{ github.event.inputs.commit_every || '5' }}"
|
|
ARGS="$ARGS --limit ${{ github.event.inputs.limit || '0' }}"
|
|
|
|
if [ -n "${{ github.event.inputs.owner_filter }}" ]; then
|
|
ARGS="$ARGS --owner-filter ${{ github.event.inputs.owner_filter }}"
|
|
fi
|
|
|
|
if [ "${{ github.event.inputs.skip_existing }}" == "false" ]; then
|
|
ARGS="$ARGS --no-skip-existing"
|
|
fi
|
|
|
|
python3 scripts/archive-repos.py $ARGS
|
|
|
|
# ── catch-all final commit for any remainder left after the last batch ─
|
|
- name: Final commit (any remainder)
|
|
run: |
|
|
git add archive/ 2>/dev/null || true
|
|
if git diff --cached --quiet; then
|
|
echo "Nothing left to commit."
|
|
exit 0
|
|
fi
|
|
|
|
COUNT=$(git diff --cached --name-only | grep -c "^archive/" || true)
|
|
git commit -m "archive: add ${COUNT} repo prompt(s) [skip ci]"
|
|
|
|
# Retry push up to 5 times, rebasing if the remote moved ahead
|
|
for i in 1 2 3 4 5; do
|
|
if git push; then
|
|
echo "Pushed successfully."
|
|
break
|
|
fi
|
|
echo "Push rejected (attempt $i/5), rebasing ..."
|
|
git pull --rebase origin main || { echo "Rebase failed — aborting."; exit 1; }
|
|
done
|