Automations: say plainly why a run was skipped to avoid a loop
The check skips a change any automation made to something this one changed in the last 10 minutes; the reason and the guide now say so. Template code on the Automations page wraps instead of clipping.
3 files+11−70/3 viewed
| 167 | 167 | ||
| 168 | 168 | - **Once per event.** An event runs each automation at most once, even if | |
| 169 | 169 | it is delivered again. | |
| 170 | − | - **No loops.** An automation does not answer an event that its own run | |
| 171 | − | caused on the same issue or pull request in the last 10 minutes. An | |
| 172 | − | automation that labels issues on `issue.updated` does not keep running | |
| 173 | − | because it labelled one. | |
| 170 | + | - **No loops.** An automation that changed an issue or pull request in | |
| 171 | + | the last 10 minutes does not answer a change to it that an automation | |
| 172 | + | made, whether itself or another. An automation that labels issues on | |
| 173 | + | `issue.updated` does not keep running because it labelled one, and two | |
| 174 | + | automations cannot set each other off. Changes people and agents make | |
| 175 | + | are answered as usual. | |
| 174 | 176 | - **A limit per hour.** An automation makes at most 30 runs an hour. | |
| 175 | 177 | Runs past the limit are skipped and recorded. Change the limit, up to | |
| 176 | 178 | 200, with: |
| 234 | 234 | <p className="font-medium">{template.title}</p> | |
| 235 | 235 | <p className="mt-1 text-xs text-muted">{template.about}</p> | |
| 236 | 236 | <p className="mt-3 font-mono text-xs text-faint">.g1t/automations/{template.file}</p> | |
| 237 | − | <pre className="mt-1.5 overflow-x-auto rounded-lg bg-bg p-3 font-mono text-xs leading-relaxed ring-1 ring-line"> | |
| 237 | + | <pre className="mt-1.5 rounded-lg bg-bg p-3 font-mono text-xs leading-relaxed break-words whitespace-pre-wrap ring-1 ring-line"> | |
| 238 | 238 | <code>{template.yaml}</code> | |
| 239 | 239 | </pre> | |
| 240 | 240 | </div> |
| 563 | 563 | .await? | |
| 564 | 564 | .is_some_and(|count| count.n > 0); | |
| 565 | 565 | if recent { | |
| 566 | − | self.finish(&run_id, "skipped", Some("This came from its own last run, so it did not answer it."), &[], actor_name.as_deref()) | |
| 567 | − | .await?; | |
| 566 | + | let reason = format!( | |
| 567 | + | "An automation made this change, and this one changed #{number} in the last 10 minutes, so it did not answer: that could loop." | |
| 568 | + | ); | |
| 569 | + | self.finish(&run_id, "skipped", Some(&reason), &[], actor_name.as_deref()).await?; | |
| 568 | 570 | return Ok(Some(run_id)); | |
| 569 | 571 | } | |
| 570 | 572 | } |