|
| 1 | +name: ClawSweeper Live Proof |
| 2 | + |
| 3 | +run-name: Live proof ${{ github.event.client_payload.repo || inputs.repo }}#${{ github.event.client_payload.item || inputs.item }} |
| 4 | + |
| 5 | +on: |
| 6 | + repository_dispatch: |
| 7 | + types: [clawsweeper_live_proof] |
| 8 | + workflow_dispatch: |
| 9 | + inputs: |
| 10 | + repo: |
| 11 | + description: "Target repository" |
| 12 | + required: true |
| 13 | + type: string |
| 14 | + item: |
| 15 | + description: "Pull request number" |
| 16 | + required: true |
| 17 | + type: string |
| 18 | + |
| 19 | +env: |
| 20 | + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true" |
| 21 | + CLAWSWEEPER_APP_CLIENT_ID: Iv23liOECG0slfuhz093 |
| 22 | + |
| 23 | +jobs: |
| 24 | + execute: |
| 25 | + runs-on: ubuntu-latest |
| 26 | + timeout-minutes: 30 |
| 27 | + permissions: {} |
| 28 | + outputs: |
| 29 | + produced: ${{ steps.run.outputs.produced }} |
| 30 | + repo: ${{ steps.target.outputs.repo }} |
| 31 | + item: ${{ steps.target.outputs.item }} |
| 32 | + repo_owner: ${{ steps.target.outputs.repo_owner }} |
| 33 | + repo_name: ${{ steps.target.outputs.repo_name }} |
| 34 | + repo_slug: ${{ steps.target.outputs.repo_slug }} |
| 35 | + steps: |
| 36 | + - uses: actions/checkout@v7 |
| 37 | + with: |
| 38 | + ref: main |
| 39 | + persist-credentials: false |
| 40 | + |
| 41 | + - name: Resolve target and decision artifact |
| 42 | + id: target |
| 43 | + env: |
| 44 | + EVENT_REPO: ${{ github.event.client_payload.repo || inputs.repo }} |
| 45 | + EVENT_ITEM: ${{ github.event.client_payload.item || inputs.item }} |
| 46 | + LIVE_PROOF_PLAN_JSON: ${{ toJSON(github.event.client_payload.live_proof_plan) }} |
| 47 | + run: | |
| 48 | + set -euo pipefail |
| 49 | + repo="$(printf '%s' "$EVENT_REPO" | tr '[:upper:]' '[:lower:]')" |
| 50 | + item="$EVENT_ITEM" |
| 51 | + if ! [[ "$repo" =~ ^[a-z0-9_.-]+/[a-z0-9_.-]+$ ]] || ! [[ "$item" =~ ^[1-9][0-9]*$ ]]; then |
| 52 | + echo "Invalid live-proof target: $repo#$item" >&2 |
| 53 | + exit 1 |
| 54 | + fi |
| 55 | + repo_owner="$(cut -d/ -f1 <<<"$repo")" |
| 56 | + repo_name="$(cut -d/ -f2 <<<"$repo")" |
| 57 | + repo_slug="$(tr / - <<<"$repo")" |
| 58 | + if [ -n "$LIVE_PROOF_PLAN_JSON" ] && [ "$LIVE_PROOF_PLAN_JSON" != "null" ]; then |
| 59 | + printf '%s\n' "$LIVE_PROOF_PLAN_JSON" | jq -e . > /tmp/live-proof-plan.json |
| 60 | + else |
| 61 | + printf '%s\n' '{"status":"not_applicable","surface":"none","reason":"Manual dispatch did not include a publication plan.","entry":"","steps":[]}' > /tmp/live-proof-plan.json |
| 62 | + echo "::notice::No publication plan was supplied; the execution gate will complete as a safe skip." |
| 63 | + fi |
| 64 | + node --input-type=module <<'NODE' |
| 65 | + import { readFileSync, writeFileSync } from "node:fs"; |
| 66 | + const plan = JSON.parse(readFileSync("/tmp/live-proof-plan.json", "utf8")); |
| 67 | + const steps = Array.isArray(plan.steps) |
| 68 | + ? plan.steps.map((step) => "- " + JSON.stringify(step)).join("\n") |
| 69 | + : ""; |
| 70 | + const report = [ |
| 71 | + "## Live Proof", |
| 72 | + "", |
| 73 | + "Status: " + String(plan.status || ""), |
| 74 | + "", |
| 75 | + "Surface: " + String(plan.surface || ""), |
| 76 | + "", |
| 77 | + "Reason: " + String(plan.reason || ""), |
| 78 | + "", |
| 79 | + "Entry: " + String(plan.entry || ""), |
| 80 | + "", |
| 81 | + "Steps:", |
| 82 | + "", |
| 83 | + steps, |
| 84 | + "", |
| 85 | + ].join("\n"); |
| 86 | + writeFileSync("live-proof-report.md", report, "utf8"); |
| 87 | + NODE |
| 88 | + { |
| 89 | + echo "repo=$repo" |
| 90 | + echo "item=$item" |
| 91 | + echo "repo_owner=$repo_owner" |
| 92 | + echo "repo_name=$repo_name" |
| 93 | + echo "repo_slug=$repo_slug" |
| 94 | + } >> "$GITHUB_OUTPUT" |
| 95 | +
|
| 96 | + - uses: ./.github/actions/setup-pnpm |
| 97 | + with: |
| 98 | + build-script: build |
| 99 | + |
| 100 | + - name: Install deterministic recording tools |
| 101 | + run: | |
| 102 | + sudo apt-get update |
| 103 | + sudo apt-get install --yes ffmpeg tmux xvfb xterm |
| 104 | +
|
| 105 | + - name: Check out the public PR head |
| 106 | + env: |
| 107 | + TARGET_REPO: ${{ steps.target.outputs.repo }} |
| 108 | + ITEM_NUMBER: ${{ steps.target.outputs.item }} |
| 109 | + run: | |
| 110 | + set -euo pipefail |
| 111 | + curl --fail --silent --show-error --max-time 30 \ |
| 112 | + "https://api.github.com/repos/$TARGET_REPO/pulls/$ITEM_NUMBER" > /tmp/live-proof-pr.json |
| 113 | + head_sha="$(jq -r '.head.sha // empty' /tmp/live-proof-pr.json)" |
| 114 | + clone_url="$(jq -r '.head.repo.clone_url // empty' /tmp/live-proof-pr.json)" |
| 115 | + if ! [[ "$head_sha" =~ ^[0-9a-f]{40}$ ]] || [ -z "$clone_url" ]; then |
| 116 | + echo "Unable to resolve the public PR head." >&2 |
| 117 | + exit 1 |
| 118 | + fi |
| 119 | + git clone --filter=blob:none --no-checkout "$clone_url" target-pr |
| 120 | + git -C target-pr fetch --depth=1 origin "$head_sha" |
| 121 | + git -C target-pr checkout --detach "$head_sha" |
| 122 | +
|
| 123 | + - name: Execute secretless live proof |
| 124 | + id: run |
| 125 | + working-directory: target-pr |
| 126 | + env: |
| 127 | + CLAWSWEEPER_LIVE_PROOF_ENABLED: ${{ vars.CLAWSWEEPER_LIVE_PROOF_ENABLED }} |
| 128 | + run: | |
| 129 | + set -euo pipefail |
| 130 | + setsid timeout --kill-after=30s 1500s node ../dist/clawsweeper.js live-proof \ |
| 131 | + --repo "${{ steps.target.outputs.repo }}" \ |
| 132 | + --item "${{ steps.target.outputs.item }}" \ |
| 133 | + --record ../live-proof-report.md \ |
| 134 | + --output ../live-proof-bundle |
| 135 | + if [ -f ../live-proof-bundle/live-proof-manifest.json ]; then |
| 136 | + echo "produced=true" >> "$GITHUB_OUTPUT" |
| 137 | + else |
| 138 | + echo "produced=false" >> "$GITHUB_OUTPUT" |
| 139 | + fi |
| 140 | +
|
| 141 | + - uses: actions/upload-artifact@v7 |
| 142 | + if: ${{ steps.run.outputs.produced == 'true' }} |
| 143 | + with: |
| 144 | + name: live-proof-${{ steps.target.outputs.repo_slug }}-${{ steps.target.outputs.item }} |
| 145 | + path: live-proof-bundle |
| 146 | + if-no-files-found: error |
| 147 | + retention-days: 7 |
| 148 | + |
| 149 | + attach: |
| 150 | + needs: execute |
| 151 | + if: ${{ needs.execute.outputs.produced == 'true' }} |
| 152 | + runs-on: ubuntu-latest |
| 153 | + timeout-minutes: 15 |
| 154 | + permissions: |
| 155 | + contents: read |
| 156 | + steps: |
| 157 | + - uses: actions/checkout@v7 |
| 158 | + with: |
| 159 | + ref: main |
| 160 | + persist-credentials: false |
| 161 | + |
| 162 | + - name: Create target write token |
| 163 | + id: target-write-token |
| 164 | + uses: ./.github/actions/create-target-write-token |
| 165 | + with: |
| 166 | + client-id: ${{ env.CLAWSWEEPER_APP_CLIENT_ID }} |
| 167 | + private-key: ${{ secrets.CLAWSWEEPER_APP_PRIVATE_KEY }} |
| 168 | + owner: ${{ needs.execute.outputs.repo_owner }} |
| 169 | + repository: ${{ needs.execute.outputs.repo_name }} |
| 170 | + |
| 171 | + - uses: ./.github/actions/setup-state |
| 172 | + with: |
| 173 | + coordinator-url: ${{ vars.CLAWSWEEPER_EXACT_REVIEW_QUEUE_URL || 'https://clawsweeper.openclaw.ai' }} |
| 174 | + records-url: ${{ vars.CLAWSWEEPER_EXACT_REVIEW_QUEUE_URL || 'https://clawsweeper.openclaw.ai' }} |
| 175 | + records-secret: ${{ secrets.CLAWSWEEPER_WEBHOOK_SECRET }} |
| 176 | + records-repo-slugs: ${{ needs.execute.outputs.repo_slug }} |
| 177 | + records-item-number: ${{ needs.execute.outputs.item }} |
| 178 | + hydrate-git-state: "false" |
| 179 | + hydrate-state-blobs: "false" |
| 180 | + |
| 181 | + - uses: ./.github/actions/setup-pnpm |
| 182 | + with: |
| 183 | + build-script: build:all |
| 184 | + |
| 185 | + - name: Install media validators |
| 186 | + run: | |
| 187 | + sudo apt-get update |
| 188 | + sudo apt-get install --yes ffmpeg |
| 189 | +
|
| 190 | + - uses: actions/download-artifact@v8 |
| 191 | + with: |
| 192 | + name: live-proof-${{ needs.execute.outputs.repo_slug }}-${{ needs.execute.outputs.item }} |
| 193 | + path: live-proof-bundle |
| 194 | + |
| 195 | + - name: Validate, upload, and attach live proof |
| 196 | + env: |
| 197 | + AWS_ACCESS_KEY_ID: ${{ secrets.CLAWSWEEPER_LIVE_PROOF_AWS_ACCESS_KEY_ID }} |
| 198 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.CLAWSWEEPER_LIVE_PROOF_AWS_SECRET_ACCESS_KEY }} |
| 199 | + CLAWSWEEPER_LIVE_PROOF_S3_ENDPOINT: ${{ secrets.CLAWSWEEPER_LIVE_PROOF_S3_ENDPOINT }} |
| 200 | + CLAWSWEEPER_LIVE_PROOF_BUCKET: ${{ secrets.CLAWSWEEPER_LIVE_PROOF_BUCKET }} |
| 201 | + CLAWSWEEPER_LIVE_PROOF_BASE_URL: ${{ secrets.CLAWSWEEPER_LIVE_PROOF_BASE_URL }} |
| 202 | + CLAWSWEEPER_WEBHOOK_SECRET: ${{ secrets.CLAWSWEEPER_WEBHOOK_SECRET }} |
| 203 | + GH_TOKEN: ${{ steps.target-write-token.outputs.token }} |
| 204 | + QUEUE_URL: ${{ vars.CLAWSWEEPER_EXACT_REVIEW_QUEUE_URL || 'https://clawsweeper.openclaw.ai' }} |
| 205 | + run: | |
| 206 | + set -euo pipefail |
| 207 | + record="records/${{ needs.execute.outputs.repo_slug }}/items/${{ needs.execute.outputs.item }}.md" |
| 208 | + node dist/clawsweeper.js live-proof-attach \ |
| 209 | + --bundle live-proof-bundle \ |
| 210 | + --record "$record" |
| 211 | + pnpm run repair:publish-main -- \ |
| 212 | + --message "chore: attach live proof" \ |
| 213 | + --path "$record" \ |
| 214 | + --rebase-strategy normal |
0 commit comments