Skip to content

Commit cf61a6b

Browse files
Merge pull request #8822 from bryan-cox/update-gha-docs-2
CNTRLPLANE-3716: Update GitHub Actions docs with slash-command workflows
2 parents 12b0f3d + 5426559 commit cf61a6b

2 files changed

Lines changed: 180 additions & 56 deletions

File tree

Lines changed: 90 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# GitHub Actions Workflows
1+
# 🔄 GitHub Actions Workflows
22

33
HyperShift uses GitHub Actions for lightweight CI checks that run on every pull request. These workflows complement the heavier Prow-based e2e tests by providing fast feedback on code quality, formatting, and documentation.
44

5-
## Reusable Workflow Architecture
5+
## 🏗️ Reusable Workflow Architecture
66

77
All GHA workflows follow a **caller + reusable** pattern:
88

@@ -23,15 +23,15 @@ flowchart LR
2323

2424
This pattern provides:
2525

26-
- **Consistency** — all PR and push workflows share the same job definitions.
27-
- **Maintainability** — job logic is defined once in the reusable workflow and updated in a single place.
28-
- **Security** — callers pin reusable workflows to `@main`, reducing the risk of PRs altering reusable job logic. Caller workflows are protected by branch protection rules and CODEOWNERS.
26+
- **Consistency** — all PR and push workflows share the same job definitions.
27+
- 🔧 **Maintainability** — job logic is defined once in the reusable workflow and updated in a single place.
28+
- 🔒 **Security** — callers pin reusable workflows to `@main`, reducing the risk of PRs altering reusable job logic. Caller workflows are protected by branch protection rules and CODEOWNERS.
2929

30-
## Workflows
30+
## 📋 Workflows
3131

3232
All workflows run on self-hosted ARC runners and target the `main` and `release-4.22` branches.
3333

34-
### Code Quality
34+
### 🧹 Code Quality
3535

3636
| Caller | Reusable | Purpose |
3737
|--------|----------|---------|
@@ -40,54 +40,116 @@ All workflows run on self-hosted ARC runners and target the `main` and `release-
4040
| `lint.yaml` | `lint-reusable.yaml` | Go linting via `golangci-lint` |
4141
| `verify.yaml` | `verify-reusable.yaml` | Full verification (`make verify`) |
4242

43-
### Testing
43+
### 🧪 Testing
4444

4545
| Caller | Reusable | Purpose |
4646
|--------|----------|---------|
4747
| `test.yaml` | `test-reusable.yaml` | Unit tests with race detection and Codecov upload |
4848
| `envtest-ocp.yaml` | `envtest-ocp-reusable.yaml` | CRD validation tests against OpenShift k8s versions |
4949
| `envtest-kube.yaml` | `envtest-kube-reusable.yaml` | CRD validation tests against vanilla k8s versions |
5050

51-
### Documentation
51+
### 📖 Documentation
5252

5353
| Caller | Reusable | Purpose |
5454
|--------|----------|---------|
5555
| `docs-build.yaml` | `docs-build-reusable.yaml` | Build MkDocs site in strict mode |
5656

57-
The `docs-deploy.yaml` workflow is not a reusable workflow pair — it triggers via `workflow_run` after the Docs Build completes to deploy the preview. See [Documentation Preview](docs-preview.md) for details.
57+
!!! info
58+
The `docs-deploy.yaml` workflow is not a reusable workflow pair — it triggers via `workflow_run` after the Docs Build completes to deploy the preview. See [Documentation Preview](docs-preview.md) for details.
5859

59-
### Other
60+
### 🤖 PR Slash Commands
61+
62+
These workflows are triggered by posting a **slash command** as a comment on a pull request. They are powered by [Claude Code](https://docs.anthropic.com/en/docs/claude-code) via the shared `reusable-claude-on-pr.yaml` workflow, which handles checking out the PR branch, authenticating to GCP (for Vertex AI), and running Claude with the appropriate prompt.
63+
64+
!!! warning "Permissions"
65+
Only organization **members**, **owners**, and **collaborators** can trigger these commands. Comments from external contributors are ignored.
66+
67+
| Command | Workflow | What it does |
68+
|---------|----------|--------------|
69+
| `/address-review-comments` | `address-review-comments.yaml` | Reads open review comments on the PR and pushes commits to address them |
70+
| `/rebase` | `rebase.yaml` | Rebases the PR branch onto the latest `main` and force-pushes |
71+
| `/restructure-commits` | `restructure-commits.yaml` | Reorganizes the PR's commits into logical units with conventional commit messages |
72+
73+
**How it works:**
74+
75+
1. Post the slash command (e.g., `/rebase`) as a comment on a PR.
76+
2. The workflow posts a 🔗 reply comment linking to the Actions run so you can follow progress.
77+
3. Claude checks out the PR branch, performs the requested operation, and pushes the result.
78+
79+
!!! tip
80+
Each command uses concurrency groups scoped to the PR number — re-triggering a command automatically cancels the previous run for that PR.
81+
82+
### 🔧 Other
6083

6184
| Caller | Reusable | Purpose |
6285
|--------|----------|---------|
6386
| `cpo-container-sync.yaml` | `cpo-container-sync-reusable.yaml` | Validate CPO container image references are in sync |
6487
| `dependabot-commit-fix.yaml` | `dependabot-commit-fix-reusable.yaml` | Rewrite dependabot commit messages to pass gitlint |
88+
| `gocacheprog-test.yaml` | `gocacheprog-test-reusable.yaml` | Tests for the `contrib/ci/gocacheprog` build cache tool (path-filtered) |
89+
| `validate-cpo-overrides.yaml` || Validate CPO override images exist and are pullable |
6590

66-
The `sync-community-fork.yaml` workflow runs on push to `main` only (not on PRs) and does not use the reusable pattern. See [Sync Community Fork](sync-community-fork.md) for details.
91+
!!! note
92+
The `sync-community-fork.yaml` workflow runs on push to `main` only (not on PRs) and does not use the reusable pattern. See [Sync Community Fork](sync-community-fork.md) for details.
6793

68-
## Adding a New Workflow
94+
## Adding a New Workflow
6995

7096
To add a new GHA workflow:
7197

72-
1. Create the reusable workflow (e.g., `my-check-reusable.yaml`) with `on: workflow_call`.
73-
2. Create the caller workflow (e.g., `my-check.yaml`) that uses the reusable workflow pinned at `@main`.
74-
3. Add branch filters for `main` and any active release branches.
98+
1. **Create the reusable workflow** (e.g., `my-check-reusable.yaml`) with `on: workflow_call`. This is where all the job logic lives.
99+
2. **Create the caller workflow** (e.g., `my-check.yaml`) that uses the reusable workflow pinned at `@main`.
100+
3. Add **branch filters** for `main` and any active release branches (e.g., `release-4.22`).
75101
4. Use `arc-runner-set` as the runner.
76102

77-
Example caller:
103+
### Post-merge runs
104+
105+
If your workflow should also run after PRs merge to `main` (e.g., for Codecov baseline uploads or post-merge validation), add `on: push` triggers **to the reusable workflow**, not the caller. This lets the reusable workflow run directly on push events without needing a separate caller.
78106

79-
```yaml
80-
name: My Check
107+
### Why callers pin to `@main`
81108

82-
on:
83-
pull_request:
84-
branches:
85-
- main
86-
- release-4.22
109+
Callers reference the reusable workflow at `@main` (e.g., `uses: openshift/hypershift/.github/workflows/my-check-reusable.yaml@main`). This means a PR **cannot modify the reusable workflow logic that runs against itself** — it always executes the version from `main`. This is a deliberate security measure: it prevents a PR from weakening checks to make itself pass.
110+
111+
!!! warning "Implication for new workflows"
112+
When you add a new reusable workflow, the caller in the same PR will **not** be able to reference it until it lands on `main`. You'll need to merge the reusable workflow first (or together with the caller, accepting that the first PR run will use a stale/missing reference).
113+
114+
??? example "Example caller workflow"
115+
```yaml
116+
name: My Check
117+
118+
on:
119+
pull_request:
120+
branches:
121+
- main
122+
- release-4.22
123+
124+
jobs:
125+
my-check:
126+
uses: openshift/hypershift/.github/workflows/my-check-reusable.yaml@main
127+
permissions:
128+
contents: read
129+
```
130+
131+
??? example "Example reusable workflow with post-merge support"
132+
```yaml
133+
name: My Check (Reusable)
134+
135+
on:
136+
workflow_call:
137+
push:
138+
branches:
139+
- main
140+
- release-4.22
87141

88-
jobs:
89-
my-check:
90-
uses: openshift/hypershift/.github/workflows/my-check-reusable.yaml@main
91142
permissions:
92143
contents: read
93-
```
144+
145+
jobs:
146+
my-check:
147+
name: My Check
148+
runs-on: arc-runner-set
149+
timeout-minutes: 60
150+
steps:
151+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
152+
with:
153+
persist-credentials: false
154+
- run: echo "Run your check here"
155+
```

docs/content/reference/aggregated-docs.md

Lines changed: 90 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)