Skip to content

Commit 5d15f31

Browse files
authored
Merge pull request #41 from CoolBitX-Technology/feat/centralize-assign-reviewers
feat: centralize reviewer assignment and update README
2 parents 8108086 + 3a1def1 commit 5d15f31

2 files changed

Lines changed: 173 additions & 23 deletions

File tree

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,37 @@
11
name: Assign Reviewers
22

3-
on:
3+
on:
4+
workflow_call:
45
pull_request:
5-
types:
6-
[ready_for_review, opened]
6+
types: [ready_for_review, opened]
7+
78
jobs:
8-
build:
9+
assign:
910
runs-on: ubuntu-latest
11+
permissions:
12+
pull-requests: write
1013
steps:
11-
- name: Assign Reviewers to PR
12-
uses: kentaro-m/auto-assign-action@v2.0.0
14+
- name: Assign reviewers
15+
uses: actions/github-script@v7
1316
with:
14-
repo-token: ${{ secrets.GITHUB_TOKEN }}
17+
script: |
18+
const REVIEWERS = [
19+
'and2352000', // Aaron
20+
'Dorac', // Dora
21+
'hankliu418', // Hank Liu
22+
'GinaYYoung', // Gina
23+
'hongyuCoolbitx', // Hongyu
24+
'suntsai-coolbitx', // Sun
25+
];
26+
27+
const author = context.payload.pull_request.user.login.toLowerCase();
28+
const reviewers = REVIEWERS.filter(r => r.toLowerCase() !== author);
29+
30+
if (reviewers.length === 0) return;
31+
32+
await github.rest.pulls.requestReviewers({
33+
owner: context.repo.owner,
34+
repo: context.repo.repo,
35+
pull_number: context.payload.pull_request.number,
36+
reviewers,
37+
});

README.md

Lines changed: 143 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,146 @@
1-
# CP-Template
2-
A repo to place github workflow templates.
1+
# cp-workflow-template
32

4-
## Folder structure
3+
Centralized GitHub Actions workflows for cp-\* repositories.
4+
5+
All reusable workflows are called via `uses: CoolBitX-Technology/cp-workflow-template/.github/workflows/<file>@master`.
6+
7+
---
8+
9+
## Reusable Workflows
10+
11+
### `assign_reviewers.yml`
12+
13+
Assigns individual reviewers to PRs. Reviewer list is maintained here — other repos only need a caller workflow.
14+
15+
```yaml
16+
jobs:
17+
assign:
18+
uses: CoolBitX-Technology/cp-workflow-template/.github/workflows/assign_reviewers.yml@master
519
```
6-
.
7-
└── workflows
8-
├── apply_terraform.yml
9-
├── assign_reviewers.yml
10-
├── build_and_test_image.yml
11-
├── notify_slack.yml
12-
├── plan_terraform.yml
13-
├── pr-action.yml
14-
├── push-action.yml
15-
├── push_and_rotate_image.yml
16-
├── run_integration_test.yml
17-
├── unit_test_than_build_image.yml
18-
└── update_pr_description.yml
20+
21+
---
22+
23+
### `build_and_test_image.yml`
24+
25+
Builds a Docker image and runs tests inside the container.
26+
27+
```yaml
28+
jobs:
29+
build:
30+
uses: CoolBitX-Technology/cp-workflow-template/.github/workflows/build_and_test_image.yml@master
31+
secrets:
32+
PROD_CP_GCP_PROJECT_ID: ${{ secrets.PROD_CP_GCP_PROJECT_ID }}
33+
DEV_CP_GCP_PROJECT_ID: ${{ secrets.DEV_CP_GCP_PROJECT_ID }}
34+
DEVOPS_READ_PACKAGE_TOKEN: ${{ secrets.DEVOPS_READ_PACKAGE_TOKEN }}
1935
```
36+
37+
---
38+
39+
### `unit_test_than_build_image.yml`
40+
41+
Runs unit tests with Node.js, then builds a Docker image and uploads it as an artifact. Prefer this over `build_and_test_image.yml` for repos with a proper unit test setup.
42+
43+
Inputs:
44+
- `node-version` (optional, default: `22.16.0`)
45+
46+
```yaml
47+
jobs:
48+
build:
49+
uses: CoolBitX-Technology/cp-workflow-template/.github/workflows/unit_test_than_build_image.yml@master
50+
with:
51+
node-version: '22.16.0'
52+
secrets:
53+
PROD_CP_GCP_PROJECT_ID: ${{ secrets.PROD_CP_GCP_PROJECT_ID }}
54+
DEV_CP_GCP_PROJECT_ID: ${{ secrets.DEV_CP_GCP_PROJECT_ID }}
55+
DEVOPS_READ_PACKAGE_TOKEN: ${{ secrets.DEVOPS_READ_PACKAGE_TOKEN }}
56+
```
57+
58+
---
59+
60+
### `push_and_rotate_image.yml`
61+
62+
Pushes the built image to GCR and rotates it in the cluster. Requires artifact from `build_and_test_image.yml` or `unit_test_than_build_image.yml`.
63+
64+
```yaml
65+
jobs:
66+
push:
67+
needs: build
68+
uses: CoolBitX-Technology/cp-workflow-template/.github/workflows/push_and_rotate_image.yml@master
69+
secrets:
70+
PROD_CP_GCP_PROJECT_ID: ${{ secrets.PROD_CP_GCP_PROJECT_ID }}
71+
DEV_CP_GCP_PROJECT_ID: ${{ secrets.DEV_CP_GCP_PROJECT_ID }}
72+
PROD_CP_GCP_SVC_TERRAFORM: ${{ secrets.PROD_CP_GCP_SVC_TERRAFORM }}
73+
DEV_CP_GCP_SVC_TERRAFORM: ${{ secrets.DEV_CP_GCP_SVC_TERRAFORM }}
74+
PROD_CP_GCP_SVC_GITHUB_RUNNER_KEY_FILE: ${{ secrets.PROD_CP_GCP_SVC_GITHUB_RUNNER_KEY_FILE }}
75+
DEV_CP_GCP_SVC_GITHUB_RUNNER_KEY_FILE: ${{ secrets.DEV_CP_GCP_SVC_GITHUB_RUNNER_KEY_FILE }}
76+
```
77+
78+
---
79+
80+
### `plan_terraform.yml` / `apply_terraform.yml`
81+
82+
Plan and apply Terraform changes. `apply_terraform.yml` typically runs after both `push_and_rotate_image` and `plan_terraform` succeed.
83+
84+
```yaml
85+
jobs:
86+
plan:
87+
needs: build
88+
uses: CoolBitX-Technology/cp-workflow-template/.github/workflows/plan_terraform.yml@master
89+
secrets:
90+
PROD_CP_GCP_PROJECT_ID: ${{ secrets.PROD_CP_GCP_PROJECT_ID }}
91+
DEV_CP_GCP_PROJECT_ID: ${{ secrets.DEV_CP_GCP_PROJECT_ID }}
92+
DEVOPS_ACCESS_REPO_TOKEN: ${{ secrets.DEVOPS_ACCESS_REPO_TOKEN }}
93+
PROD_CP_GCP_SVC_GITHUB_RUNNER_KEY_FILE: ${{ secrets.PROD_CP_GCP_SVC_GITHUB_RUNNER_KEY_FILE }}
94+
DEV_CP_GCP_SVC_GITHUB_RUNNER_KEY_FILE: ${{ secrets.DEV_CP_GCP_SVC_GITHUB_RUNNER_KEY_FILE }}
95+
96+
apply:
97+
needs: [push, plan]
98+
uses: CoolBitX-Technology/cp-workflow-template/.github/workflows/apply_terraform.yml@master
99+
secrets: ...
100+
```
101+
102+
---
103+
104+
### `run_integration_test.yml`
105+
106+
Runs integration tests and notifies a Slack user on completion.
107+
108+
Required inputs: `OWNER_SLACK_ID`, `SERVICE`.
109+
110+
---
111+
112+
### `notify_slack.yml`
113+
114+
Sends a Slack notification to the crypto platform channel.
115+
116+
```yaml
117+
jobs:
118+
notify:
119+
needs: apply
120+
uses: CoolBitX-Technology/cp-workflow-template/.github/workflows/notify_slack.yml@master
121+
secrets:
122+
CP_SLACK_CHANNEL_RG_CRYPTO: ${{ secrets.CP_SLACK_CHANNEL_RG_CRYPTO }}
123+
```
124+
125+
---
126+
127+
### `build_and_publish_npm_package.yml`
128+
129+
Builds and publishes a package to the GitHub Packages (private `@coolbitx-technology` registry).
130+
131+
---
132+
133+
### `build_and_publish_official_public_npm_package.yml`
134+
135+
Builds and publishes a package to the public npmjs.org registry under `@coolbitx` scope.
136+
137+
---
138+
139+
## Standalone Workflows
140+
141+
| File | Trigger | Purpose |
142+
|---|---|---|
143+
| `push-action.yml` | `push` / `workflow_dispatch` | Example: composes build → push → terraform → notify |
144+
| `pr-action.yml` | `pull_request` | Example: Docker-based unit test + Slack notification |
145+
| `update_pr_description.yml` | `pull_request` → `master` | Auto-updates PR description |
146+
| `delete-failure-job.yml` | `workflow_dispatch` | Manually delete a failed k8s CronJob by namespace + name |

0 commit comments

Comments
 (0)