mirror of
https://github.com/prdlk/leetcode.git
synced 2026-09-17 07:26:27 +00:00
Add SRS automation: scheduler, logger, weekly gates
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
name: Gate
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 12 * * 6" # Saturday 8 AM ET — create this week's gate
|
||||
workflow_dispatch:
|
||||
issues:
|
||||
types: [closed] # grade a gate when it closes
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
issues: write
|
||||
|
||||
# Shared with srs-scheduler / srs-logger / srs-setup: never race on srs.json.
|
||||
concurrency:
|
||||
group: srs-state
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
create:
|
||||
# Trigger A: the only issue-creating workflow in the SRS. The script
|
||||
# no-ops when this week's gate already exists.
|
||||
if: github.event_name != 'issues'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
|
||||
- run: bun scripts/srs-gate.ts create
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Commit state
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
git add .github/srs
|
||||
git diff --cached --quiet && { echo "no state change"; exit 0; }
|
||||
git commit -m "srs: create weekly gate [skip ci]"
|
||||
for i in 1 2 3; do git push && exit 0; git pull --rebase; done
|
||||
git push
|
||||
|
||||
close:
|
||||
# Trigger B: grade, log, boost, badge.
|
||||
if: >-
|
||||
github.event_name == 'issues' &&
|
||||
contains(github.event.issue.labels.*.name, 'gate')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
|
||||
- run: bun scripts/srs-gate.ts close
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Commit state
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
git add .github/srs docs/gate-log.md
|
||||
git diff --cached --quiet && { echo "no state change"; exit 0; }
|
||||
git commit -m "srs: grade gate #${{ github.event.issue.number }} [skip ci]"
|
||||
for i in 1 2 3; do git push && exit 0; git pull --rebase; done
|
||||
git push
|
||||
Reference in New Issue
Block a user