Skip to content

feat: create pull-request-code-checks #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 26, 2025
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
36 changes: 36 additions & 0 deletions .github/workflows/pull-request-code-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: pull-request-code-checks

on:
pull_request_review:
branches:
- main
types: [ submitted ]

jobs:
build:
name: Build
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup

- name: Build
run: yarn build

lint:
name: Lint
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup

- name: Lint
run: yarn lint
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ approach to the bypass procedure.
This workflow shows how to pass artifacts from one job to another.
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.

### Pull Request Code Checks

This workflow shows how to run code checks on a pull request that targets the main branch, it runs the `build` and `lint`
scripts.
Take a look at the [pull-request-code-checks](./docs/pull-request-code-checks.md) document to see how to set it up.

## Useful links

- [Github Actions Documentation](https://docs.github.com/en/actions)
Expand Down
53 changes: 53 additions & 0 deletions docs/pull-request-code-checks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Pull request code checks

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
that it is up to the standards of the project.
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
limits of the Github Actions free tier.

Take a look at the following example:

```yaml

name: pull-request-code-checks

on:
# (1) Run the workflow only when a pull request is:
# - opened against the main branch
# - and a review is submitted
pull_request_review:
branches:
- main
types: [ submitted ]

jobs:
build:
name: Build
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup

- name: Build
run: yarn build

lint:
name: Lint
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup

- name: Lint
run: yarn lint

```

Loading