Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
f5daefc
feat: create individual actions
teodorus-nathaniel Dec 22, 2025
388958f
feat: create single action aggregator
teodorus-nathaniel Dec 22, 2025
9e1be5e
fix: use hardcoded repo name
teodorus-nathaniel Dec 22, 2025
6b47acd
feat: call pr checks on push
teodorus-nathaniel Dec 22, 2025
497409b
refactor: use relative path
teodorus-nathaniel Dec 22, 2025
e634075
chore: remove version pinning on local workflow
teodorus-nathaniel Dec 22, 2025
00c58a4
fix: install config conventional locally
teodorus-nathaniel Dec 22, 2025
64c0c30
chore: not run prettier check on this repo
teodorus-nathaniel Dec 22, 2025
96b6850
feat: add checksum check
teodorus-nathaniel Dec 22, 2025
0f97192
docs: add readme
teodorus-nathaniel Dec 22, 2025
1ff46b8
chore: run prettier check here
teodorus-nathaniel Dec 22, 2025
be8820a
feat: add prettier in this repo for development
teodorus-nathaniel Dec 22, 2025
bbc4c39
chore: use pnpm 10
teodorus-nathaniel Dec 22, 2025
9655732
feat: add package json path for version managing
teodorus-nathaniel Dec 22, 2025
50517ca
feat: add additional custom package json path
teodorus-nathaniel Dec 22, 2025
971bed7
fix: remove version in pnpm action setup
teodorus-nathaniel Dec 22, 2025
25831c4
refactor: rename package_json_path to package_json_file
teodorus-nathaniel Dec 22, 2025
1743656
chore: update readme
teodorus-nathaniel Dec 22, 2025
20e0836
feat: add default value because running from workflow doesn't have th…
teodorus-nathaniel Dec 22, 2025
5e252d1
refactor: extract the package json default to another step
teodorus-nathaniel Dec 22, 2025
44a97bc
refactor: use default value in pr checks
teodorus-nathaniel Dec 22, 2025
62ac472
docs: add custom package json file input
teodorus-nathaniel Dec 22, 2025
a8baa55
chore: use bun instead of pnpm
teodorus-nathaniel Dec 22, 2025
4009909
feat: use bun instead of pnpm
teodorus-nathaniel Dec 22, 2025
c7c6b37
chore: remove unused inputs
teodorus-nathaniel Dec 22, 2025
f41359f
fix: wrong input usage of prettier
teodorus-nathaniel Dec 22, 2025
554afed
chore: remove package json check
teodorus-nathaniel Dec 22, 2025
f8a62af
feat: add back prettier cehck in package json
teodorus-nathaniel Dec 22, 2025
9fff902
chore: add clearer error message
teodorus-nathaniel Dec 22, 2025
9d1d777
chore: add pr checks self
teodorus-nathaniel Dec 22, 2025
44c76dc
chore: remove version
teodorus-nathaniel Dec 22, 2025
10dc04c
chore: remove commit messages check
teodorus-nathaniel Dec 22, 2025
9cbd22b
docs: update readme
teodorus-nathaniel Dec 22, 2025
3c9ae2e
docs: remove package_json_file
teodorus-nathaniel Dec 22, 2025
fa737d1
docs: remove unnecessary constraint
teodorus-nathaniel Dec 22, 2025
56a14cf
chore: use yml instead of json config
teodorus-nathaniel Dec 23, 2025
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
34 changes: 34 additions & 0 deletions .github/workflows/commit-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Conventional Commit Check for PR Title

on:
workflow_call:

jobs:
commit-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Install commitlint
run: |
bun i -g @commitlint/cli
bun i -D @commitlint/config-conventional

- name: Create commitlint config if missing
run: |
if [ ! -f .commitlintrc.json ] && [ ! -f .commitlintrc.js ] && [ ! -f .commitlintrc.yml ] && [ ! -f .commitlintrc.yaml ] && ! grep -q '"commitlint"' "package.json" 2>/dev/null; then
echo "extends:" > .commitlintrc.yml
echo " - '@commitlint/config-conventional'" >> .commitlintrc.yml
fi

- name: Check PR title
if: github.event_name == 'pull_request'
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
echo "$PR_TITLE" | commitlint
23 changes: 23 additions & 0 deletions .github/workflows/markdown-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Markdown Lint

on:
workflow_call:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install rumdl pre-compiled binary
# EXPECTED_SHA256 is obtained from `curl -sL $DOWNLOAD_URL | sha256sum`
run: |
DOWNLOAD_URL="https://github.com/rvben/rumdl/releases/download/v0.0.185/rumdl-v0.0.185-x86_64-unknown-linux-gnu.tar.gz"
EXPECTED_SHA256="5e6f28fa4935fb7d022c4f2d64f82b12206038d17e6570466afe7d7a3b135fba"
curl -sL $DOWNLOAD_URL -o /tmp/rumdl.tar.gz
echo "$EXPECTED_SHA256 /tmp/rumdl.tar.gz" | sha256sum -c -
tar -xzf /tmp/rumdl.tar.gz -C /usr/local/bin/
chmod +x /usr/local/bin/rumdl
- name: Lint Markdown
run: rumdl check --output-format github .
9 changes: 9 additions & 0 deletions .github/workflows/pr-checks-self.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: PR Checks

on:
pull_request:
types: [opened, reopened, synchronize, ready_for_review]

jobs:
checks:
uses: ./.github/workflows/pr-checks.yml
55 changes: 55 additions & 0 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: PR Checks

on:
workflow_call:
inputs:
run-prettier:
description: "Run Prettier check"
required: false
type: boolean
default: true
run-markdown:
description: "Run Markdown check"
required: false
type: boolean
default: true
run-commits:
description: "Run Commit check"
required: false
type: boolean
default: true

jobs:
check-draft:
runs-on: ubuntu-latest
outputs:
should-run: ${{ steps.check.outputs.should-run }}
steps:
- id: check
run: |
if [ "${{ github.event_name }}" != "pull_request" ] || [ "${{ github.event.pull_request.draft }}" != "true" ]; then
echo "should-run=true" >> $GITHUB_OUTPUT
else
echo "should-run=false" >> $GITHUB_OUTPUT
fi

prettier:
needs: check-draft
if:
needs.check-draft.outputs.should-run == 'true' && inputs.run-prettier !=
false
uses: ./.github/workflows/prettier.yml

markdown:
needs: check-draft
if:
needs.check-draft.outputs.should-run == 'true' && inputs.run-markdown !=
false
uses: ./.github/workflows/markdown-check.yml

commits:
needs: check-draft
if:
needs.check-draft.outputs.should-run == 'true' && inputs.run-commits !=
false
uses: ./.github/workflows/commit-check.yml
41 changes: 41 additions & 0 deletions .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Prettier Check

on:
workflow_call:

jobs:
prettier:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Check for Prettier config
run: |
CONFIG_FILES=".prettierrc .prettierrc.json .prettierrc.js .prettierrc.yaml .prettierrc.yml .prettierrc.toml prettier.config.js prettier.config.mjs"
HAS_CONFIG=false

for file in $CONFIG_FILES; do
if [ -f "$file" ]; then
HAS_CONFIG=true
break
fi
done

if [ "$HAS_CONFIG" = false ] && ! grep -q '"prettier"' "package.json" 2>/dev/null; then
echo "::error file=.prettierrc::No Prettier configuration file found."
echo "A Prettier config file is required to ensure consistent formatting across all developers."
echo "Without a shared config, each developer's local Prettier settings will differ, causing unnecessary formatting changes in commits."
echo "Please create a .prettierrc file in your repository root."
exit 1
fi

- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Install Prettier
run: bun i -g prettier

- name: Check formatting
run: prettier --check .
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm-lock.yaml
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"printWidth": 80,
"proseWrap": "always",
"singleQuote": false
}
158 changes: 157 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,157 @@
# Github Actions
# GitHub Actions

Shared GitHub Actions workflows for consistent code quality checks across
repositories.

## Available Workflows

This repository provides reusable workflows for:

- **Prettier Check** - Validates code formatting with Prettier
- **Markdown Lint** - Lints Markdown files using rumdl
- **Conventional Commit Check for PR Title** - Validates PR titles follow
conventional commit format
- **PR Checks** - Combined workflow that runs all checks (or selected ones) with
draft PR handling

## Usage

### Option 1: Combined Workflow (Recommended for Simple Setup)

Use the combined `pr-checks.yml` workflow to run all checks at once. This
workflow automatically handles draft PRs and runs all checks by default.

#### Basic Usage

Create `.github/workflows/pr-checks.yml` in your repository:

```yaml
name: PR Checks

on:
pull_request:
types: [opened, reopened, synchronize, ready_for_review]

jobs:
checks:
uses: holdex/github-actions/.github/workflows/pr-checks.yml@main
```

#### Selective Checks

To run only specific checks, pass input flags:

```yaml
name: PR Checks

on:
pull_request:
types: [opened, reopened, synchronize, ready_for_review]

jobs:
checks:
uses: holdex/github-actions/.github/workflows/pr-checks.yml@main
with:
run-prettier: true
run-markdown: false # Skip markdown check
run-commits: true
```

### Option 2: Individual Workflows

Use individual workflows for granular control over when each check runs.

#### Prettier Check

```yaml
name: Prettier Check

on:
pull_request:
types: [opened, reopened, synchronize]

jobs:
prettier:
uses: holdex/github-actions/.github/workflows/prettier.yml@main
```

**Requirements:**

- Prettier configuration file (`.prettierrc`, `.prettierrc.json`, etc.) or
`prettier` config in `package.json`

#### Markdown Lint

```yaml
name: Markdown Lint

on:
pull_request:
types: [opened, reopened, synchronize]

jobs:
markdown:
uses: holdex/github-actions/.github/workflows/markdown-check.yml@main
```

#### Conventional Commit Check

```yaml
name: Commit Check

on:
pull_request:
types: [opened, reopened, synchronize]

jobs:
commits:
uses: holdex/github-actions/.github/workflows/commit-check.yml@main
```

**Requirements:**

- Commitlint configuration file (`.commitlintrc.json`, etc.) or `commitlint`
config in `package.json`
- If no config exists, the workflow will create a default `.commitlintrc.json`
file

## Workflow Details

### PR Checks (`pr-checks.yml`)

The combined workflow includes:

- **Draft PR handling** - Automatically skips checks for draft PRs
- **Selective execution** - Control which checks run via inputs
- **Default behavior** - Runs all checks if no inputs specified

**Inputs:**

- `run-prettier` (boolean, default: `true`) - Run Prettier check
- `run-markdown` (boolean, default: `true`) - Run Markdown lint
- `run-commits` (boolean, default: `true`) - Run commit check

### Prettier Check (`prettier.yml`)

- Validates that a Prettier configuration exists
- Checks code formatting using Prettier
- Supports all Prettier-supported file types
- Uses Bun for package management

### Markdown Lint (`markdown-check.yml`)

- Uses `rumdl` v0.0.185 for fast Markdown linting
- Checks all Markdown files in the repository
- Reports issues with GitHub annotations

### Conventional Commit Check (`commit-check.yml`)

- Validates PR titles follow conventional commit format
- Creates default commitlint config if missing (requires `package.json`)
- Uses Bun for package management

## Requirements

- Node.js 22+
- Bun (installed automatically in workflows)
- Uses the latest version of Bun
15 changes: 15 additions & 0 deletions bun.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"lockfileVersion": 1,
"configVersion": 1,
"workspaces": {
"": {
"name": "github-actions",
"devDependencies": {
"prettier": "^3.7.4",
},
},
},
"packages": {
"prettier": ["prettier@3.7.4", "", { "bin": { "prettier": "bin/prettier.cjs" } }, "sha512-v6UNi1+3hSlVvv8fSaoUbggEM5VErKmmpGA7Pl3HF8V6uKY7rvClBOJlH6yNwQtfTueNkGVpOv/mtWL9L4bgRA=="],
}
}
16 changes: 16 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "github-actions",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"format": "prettier --write ."
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"prettier": "^3.7.4"
}
}