Skip to content

Commit 5b832c3

Browse files
authored
feat: create pull-request-code-checks (#7)
* feat: create pull-request-code-checks workflow * feat: update pull-request-code-checks to run only when pr is approved * docs: create pull-request-code-checks * chore: update readme with newly created workflow
1 parent 8e2b6b7 commit 5b832c3

File tree

3 files changed

+95
-0
lines changed

3 files changed

+95
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: pull-request-code-checks
2+
3+
on:
4+
pull_request_review:
5+
branches:
6+
- main
7+
types: [ submitted ]
8+
9+
jobs:
10+
build:
11+
name: Build
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Setup
19+
uses: ./.github/actions/setup
20+
21+
- name: Build
22+
run: yarn build
23+
24+
lint:
25+
name: Lint
26+
runs-on: ubuntu-latest
27+
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
32+
- name: Setup
33+
uses: ./.github/actions/setup
34+
35+
- name: Lint
36+
run: yarn lint

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ approach to the bypass procedure.
2424
This workflow shows how to pass artifacts from one job to another.
2525
Take a look at the [pass-artifacts-to-next-job](./docs/pass-artifacts-to-next-jobs.md) document to see how to set it up.
2626

27+
### Pull Request Code Checks
28+
29+
This workflow shows how to run code checks on a pull request that targets the main branch, it runs the `build` and `lint`
30+
scripts.
31+
Take a look at the [pull-request-code-checks](./docs/pull-request-code-checks.md) document to see how to set it up.
32+
2733
## Useful links
2834

2935
- [Github Actions Documentation](https://docs.github.com/en/actions)

docs/pull-request-code-checks.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Pull request code checks
2+
3+
When a new pull request is opened against the main branch, it is a good idea to run some checks on the code to make sure
4+
that it is up to the standards of the project.
5+
You can run it on every push, but it is better to run it only when a pull request is approved, to avoid reaching the
6+
limits of the Github Actions free tier.
7+
8+
Take a look at the following example:
9+
10+
```yaml
11+
12+
name: pull-request-code-checks
13+
14+
on:
15+
# (1) Run the workflow only when a pull request is:
16+
# - opened against the main branch
17+
# - and a review is submitted
18+
pull_request_review:
19+
branches:
20+
- main
21+
types: [ submitted ]
22+
23+
jobs:
24+
build:
25+
name: Build
26+
runs-on: ubuntu-latest
27+
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
32+
- name: Setup
33+
uses: ./.github/actions/setup
34+
35+
- name: Build
36+
run: yarn build
37+
38+
lint:
39+
name: Lint
40+
runs-on: ubuntu-latest
41+
42+
steps:
43+
- name: Checkout
44+
uses: actions/checkout@v4
45+
46+
- name: Setup
47+
uses: ./.github/actions/setup
48+
49+
- name: Lint
50+
run: yarn lint
51+
52+
```
53+

0 commit comments

Comments
 (0)