Weekly backup main → backups/main #2
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: Weekly backup main → backups/main | |
| # Mirrors the current tip of `main` onto `backups/main` so we always have | |
| # a one-PR-away restore point if main gets corrupted by a Sync-fork | |
| # misclick, a bad merge, or anything else surprising. | |
| # | |
| # Why `backups/main` and not `main-backup`: | |
| # the repo ruleset on `linways/lwchat` covers `main` AND `main-backup` | |
| # (likely via a `main*` pattern), enforcing "Changes must be made through | |
| # a pull request". The default GITHUB_TOKEN cannot bypass that rule, so | |
| # the first attempt at this job (run #1) failed with GH013. The | |
| # `backups/*` namespace is outside the rule, so the action token can | |
| # write there directly. | |
| # | |
| # Schedule: every Saturday 22:00 IST (= 16:30 UTC, day-of-week 6). | |
| # Cron is in UTC; IST = UTC+5:30, so 22:00 IST → 16:30 UTC. | |
| on: | |
| schedule: | |
| - cron: "30 16 * * 6" | |
| workflow_dispatch: # also allow manual runs from the Actions tab | |
| jobs: | |
| mirror: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # needed to push to backups/main | |
| steps: | |
| - name: Checkout main | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| fetch-depth: 0 # full history so the push lands cleanly | |
| - name: Force-push main → backups/main | |
| run: | | |
| set -euo pipefail | |
| echo "Mirroring $(git rev-parse HEAD) to refs/heads/backups/main" | |
| git push --force origin HEAD:refs/heads/backups/main |