Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions examples/github-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ concurrency:

jobs:
react:
# If CI intentionally hands off from a protected release branch, replace
# the default-branch guard below with that exact branch name.
if: >-
(
github.event_name != 'pull_request_target' ||
Expand All @@ -45,6 +47,22 @@ jobs:
github.event.pull_request.head.repo.full_name == github.repository
)
) &&
(
github.event_name != 'workflow_run' ||
(
contains(
fromJSON(
'["action_required","cancelled","failure","neutral","skipped","stale","startup_failure","success","timed_out"]'
),
github.event.workflow_run.conclusion
) &&
github.event.workflow_run.event != 'pull_request' &&
github.event.workflow_run.event != 'pull_request_target' &&
github.event.workflow_run.head_repository.full_name == github.repository &&
github.event.workflow_run.head_branch ==
github.event.repository.default_branch
)
) &&
(
github.event_name != 'check_suite' ||
(
Expand Down
16 changes: 16 additions & 0 deletions tests/test_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,22 @@ def test_github_workflow_wakes_after_named_ci_finishes(self) -> None:
self.assertIn('cron: "*/5 * * * *"', workflow)
self.assertIn("workflows: [CI]", workflow)
self.assertIn("github.event.repository.default_branch", workflow)
self.assertNotIn("branches: [main]", workflow)
self.assertIn("fromJSON(", workflow)
self.assertIn("github.event.workflow_run.conclusion", workflow)
self.assertIn('"success"', workflow)
self.assertIn('"stale"', workflow)
self.assertIn('"startup_failure"', workflow)
self.assertIn('"timed_out"', workflow)
self.assertIn("github.event.workflow_run.event != 'pull_request'", workflow)
self.assertIn(
"github.event.workflow_run.event != 'pull_request_target'", workflow
)
self.assertIn("github.event.workflow_run.head_repository.full_name", workflow)
self.assertIn("github.event.workflow_run.head_branch", workflow)
self.assertIn("protected release", workflow)
condition = workflow.split(" if: >-\n", 1)[1].split(" runs-on:", 1)[0]
self.assertNotIn("#", condition)
self.assertIn(
"github.event.pull_request.head.repo.full_name == github.repository",
workflow,
Expand Down