From 0222cf3af3d95791ab22736902b7740d9d8a44d2 Mon Sep 17 00:00:00 2001 From: faisalishfaq2005 Date: Mon, 29 Jun 2026 19:39:59 +0500 Subject: [PATCH] docs: add runnable GitHub Action example for scheduled loops MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The README promised a ~20-line GitHub Action for running a loop on a schedule but never shipped one. Adds examples/github-action-docs-sync.yml — a copy-pasteable workflow that runs the docs-sync loop weekly and opens a PR from the loop's changes — and links it from the README. Co-Authored-By: Claude Opus 4.8 --- README.md | 2 +- examples/github-action-docs-sync.yml | 58 ++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 examples/github-action-docs-sync.yml diff --git a/README.md b/README.md index 00b6ea9..9da33e3 100644 --- a/README.md +++ b/README.md @@ -189,7 +189,7 @@ schtasks /create /tn "debt-audit" /sc weekly /d MON /st 09:00 ^ /tr "cmd /c cd /d C:\path\to\project && loopflow run debt-audit" ``` -CI works too — a GitHub Action that runs `loopflow run docs-sync` weekly and opens a PR from the kept worktree branch is ~20 lines. +CI works too — a GitHub Action that runs `loopflow run docs-sync` weekly and opens a PR from the kept worktree branch is ~20 lines. Copy [`examples/github-action-docs-sync.yml`](examples/github-action-docs-sync.yml) into your project to get started. ## Staying the engineer diff --git a/examples/github-action-docs-sync.yml b/examples/github-action-docs-sync.yml new file mode 100644 index 0000000..d63f999 --- /dev/null +++ b/examples/github-action-docs-sync.yml @@ -0,0 +1,58 @@ +# Example: run a LoopFlow loop on a schedule and open a PR with the results. +# +# Copy this into YOUR project at: +# .github/workflows/loopflow-docs-sync.yml +# +# It runs the `docs-sync` loop every Monday, and if the loop leaves changes +# behind, opens a pull request for a human to review. Nothing is merged +# automatically — the loop proposes, you dispose. +# +# Prerequisites in your repo: +# 1. `loopflow init` has been run and `.loopflow/loops/docs-sync.yaml` exists. +# 2. A repo secret holding your Claude credentials (see the auth note below). + +name: Weekly docs-sync +on: + schedule: + - cron: "0 9 * * 1" # Mondays at 09:00 UTC — adjust to taste + workflow_dispatch: {} # also lets you trigger it by hand from the Actions tab + +jobs: + docs-sync: + runs-on: ubuntu-latest + permissions: + contents: write # allow pushing the loop's branch + pull-requests: write # allow opening the PR + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 20 + + # LoopFlow drives Claude Code, so both must be installed. + - run: npm install -g @loopflow/cli @anthropic-ai/claude-code + + # AUTH NOTE: Claude Code must be authenticated in CI. The simplest path + # is an API key exposed as ANTHROPIC_API_KEY. If your setup uses a + # different auth method (OAuth token, Bedrock, Vertex), swap this for the + # matching environment variables — "if `claude` works, `loopflow` works." + - name: Run the docs-sync loop + env: + ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} + run: loopflow run docs-sync + + # The docs-sync loop uses `worktree: true`, so when it makes changes it + # leaves them on a branch. create-pull-request picks up any working-tree + # changes and opens (or updates) a single PR. + - name: Open a PR if the loop made changes + uses: peter-evans/create-pull-request@v6 + with: + branch: loopflow/docs-sync + title: "docs-sync: loop-proposed documentation fixes" + commit-message: "docs: sync docs with code (loopflow)" + body: | + Automated by the LoopFlow `docs-sync` loop. + + A separate agent verified these changes against the source, but + **review before merging** — the loop proposes, you dispose.