Skip to content
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
6 changes: 6 additions & 0 deletions .github/actions/base/commit-check/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ runs:
- name: Install commitlint CLI
if: github.event_name == 'pull_request'
shell: bash
working-directory: ${{ env.HOLDEX_WORKING_DIR || '.' }}
run: |
if [ "${{ inputs.package-manager }}" = "pnpm" ]; then
pnpm add -g @commitlint/cli
Expand All @@ -26,6 +27,7 @@ runs:
id: commitlint-config
if: github.event_name == 'pull_request'
shell: bash
working-directory: ${{ env.HOLDEX_WORKING_DIR || '.' }}
run: |
CONFIG_FILES=".commitlintrc .commitlintrc.json .commitlintrc.yaml .commitlintrc.yml .commitlintrc.js .commitlintrc.cjs .commitlintrc.mjs .commitlintrc.ts .commitlintrc.cts commitlint.config.js commitlint.config.cjs commitlint.config.mjs commitlint.config.ts commitlint.config.cts"
HAS_CONFIG=false
Expand All @@ -50,6 +52,7 @@ runs:
- name: Install dependencies if config exists
if: github.event_name == 'pull_request' && steps.commitlint-config.outputs.has-config == 'true'
shell: bash
working-directory: ${{ env.HOLDEX_WORKING_DIR || '.' }}
run: |
if [ "${{ inputs.package-manager }}" = "pnpm" ]; then
pnpm install --frozen-lockfile
Expand All @@ -62,6 +65,7 @@ runs:
- name: Install commitlint globally if no config
if: github.event_name == 'pull_request' && steps.commitlint-config.outputs.has-config == 'false'
shell: bash
working-directory: ${{ env.HOLDEX_WORKING_DIR || '.' }}
run: |
if [ "${{ inputs.package-manager }}" = "pnpm" ]; then
pnpm add -D @commitlint/config-conventional
Expand All @@ -74,13 +78,15 @@ runs:
- name: Create commitlint config if missing
if: github.event_name == 'pull_request' && steps.commitlint-config.outputs.has-config == 'false'
shell: bash
working-directory: ${{ env.HOLDEX_WORKING_DIR || '.' }}
run: |
echo "extends:" > .commitlintrc.yml
echo " - '@commitlint/config-conventional'" >> .commitlintrc.yml

- name: Check PR title
if: github.event_name == 'pull_request'
shell: bash
working-directory: ${{ env.HOLDEX_WORKING_DIR || '.' }}
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
Expand Down
4 changes: 4 additions & 0 deletions .github/actions/base/markdown-check/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ runs:
- name: Resolve changed markdown files
id: resolved-markdown-files
shell: bash
working-directory: ${{ env.HOLDEX_WORKING_DIR || '.' }}
run: |
if [ -z "${{ inputs.changed-files }}" ]; then
echo "any-changed=${{ steps.changed-markdown-files.outputs.any_changed }}" >> "$GITHUB_OUTPUT"
Expand Down Expand Up @@ -53,6 +54,7 @@ runs:
- name: Install rumdl
if: steps.resolved-markdown-files.outputs.any-changed == 'true'
shell: bash
working-directory: ${{ env.HOLDEX_WORKING_DIR || '.' }}
run: |
if [ "${{ inputs.package-manager }}" = "pnpm" ]; then
pnpm add -g rumdl
Expand All @@ -65,9 +67,11 @@ runs:
- name: Skip when no markdown files changed
if: steps.resolved-markdown-files.outputs.any-changed != 'true'
shell: bash
working-directory: ${{ env.HOLDEX_WORKING_DIR || '.' }}
run: echo "No changed Markdown files to lint."

- name: Lint changed Markdown files
if: steps.resolved-markdown-files.outputs.any-changed == 'true'
shell: bash
working-directory: ${{ env.HOLDEX_WORKING_DIR || '.' }}
run: rumdl check --output-format github --fail-on error ${{ steps.resolved-markdown-files.outputs.files }}
6 changes: 6 additions & 0 deletions .github/actions/base/prettier/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ runs:
- name: Resolve changed files
id: resolved-files
shell: bash
working-directory: ${{ env.HOLDEX_WORKING_DIR || '.' }}
run: |
if [ -n "${{ inputs.changed-files }}" ]; then
echo "any-changed=true" >> "$GITHUB_OUTPUT"
Expand All @@ -34,6 +35,7 @@ runs:
- name: Install Prettier
if: steps.resolved-files.outputs.any-changed == 'true'
shell: bash
working-directory: ${{ env.HOLDEX_WORKING_DIR || '.' }}
run: |
if [ "${{ inputs.package-manager }}" = "pnpm" ]; then
pnpm add -g prettier
Expand All @@ -47,6 +49,7 @@ runs:
id: prettier-config
if: steps.resolved-files.outputs.any-changed == 'true'
shell: bash
working-directory: ${{ env.HOLDEX_WORKING_DIR || '.' }}
run: |
probe_file=".prettier-config-probe.tmp"
touch "$probe_file"
Expand All @@ -68,6 +71,7 @@ runs:
- name: Install dependencies
if: steps.resolved-files.outputs.any-changed == 'true'
shell: bash
working-directory: ${{ env.HOLDEX_WORKING_DIR || '.' }}
run: |
if [ -f package.json ]; then
if [ "${{ inputs.package-manager }}" = "pnpm" ]; then
Expand All @@ -84,9 +88,11 @@ runs:
- name: Skip when no files changed
if: steps.resolved-files.outputs.any-changed != 'true'
shell: bash
working-directory: ${{ env.HOLDEX_WORKING_DIR || '.' }}
run: echo "No changed files to check with Prettier."

- name: Check formatting
if: steps.resolved-files.outputs.any-changed == 'true'
shell: bash
working-directory: ${{ env.HOLDEX_WORKING_DIR || '.' }}
run: prettier --check --ignore-unknown ${{ steps.resolved-files.outputs.files }}
1 change: 1 addition & 0 deletions .github/actions/base/setup-runtime/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ runs:
if: inputs.package-manager == 'pnpm'
id: pnpm-package-manager
shell: bash
working-directory: ${{ env.HOLDEX_WORKING_DIR || '.' }}
run: |
if [ ! -f package.json ]; then
echo "has-pnpm-package-manager=false" >> "$GITHUB_OUTPUT"
Expand Down
14 changes: 14 additions & 0 deletions .github/actions/composed/pr-checks/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,24 @@ inputs:
description: Package manager to use (bun, pnpm, or npm)
required: false
default: "bun"
working-directory:
description: Working directory to run checks in
required: false
default: "."

runs:
using: composite
steps:
- name: Set working directory
shell: bash
run: |
dir="${HOLDEX_WORKING_DIR:-${{ inputs.working-directory }}}"
if [ ! -d "$dir" ]; then
echo "Error: working-directory '$dir' does not exist." >&2
exit 1
fi
echo "HOLDEX_WORKING_DIR=$dir" >> "$GITHUB_ENV"

Comment thread
coderabbitai[bot] marked this conversation as resolved.
- name: Get changed files
id: changed-files
if:
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ on:
required: false
type: string
default: main
working-directory:
description: "Working directory to run checks in"
required: false
type: string
default: "."

jobs:
checks:
Expand All @@ -40,6 +45,10 @@ jobs:
with:
ref: ${{ inputs.ref }}

- name: Set working directory
shell: bash
run: echo "HOLDEX_WORKING_DIR=${{ inputs.working-directory }}" >> $GITHUB_ENV

- name: Setup runtime
uses: ./.holdex-actions/.github/actions/base/setup-runtime
with:
Expand All @@ -52,3 +61,4 @@ jobs:
run-markdown: ${{ inputs.run-markdown }}
run-commits: ${{ inputs.run-commits }}
package-manager: ${{ inputs.package-manager }}
working-directory: ${{ inputs.working-directory }}
38 changes: 38 additions & 0 deletions ACTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
- Intended as the first step before calling local-path actions from that checkout.

> [!WARNING]
> Keep `base/checkout` backward compatible. Workflows reference the action as `.../base/checkout@main`, so any breaking change merged to this repo’s `main` will immediately break consumers.

Check warning on line 28 in ACTIONS.md

View workflow job for this annotation

GitHub Actions / checks / checks

MD013

Line length 189 exceeds 80 characters
>
> This also applies to the `ref` input: existing workflows often pass `ref: main` (a branch name) for the _target_ repo checkout, so don’t change `ref` semantics in a way that would require a commit SHA.

Check warning on line 30 in ACTIONS.md

View workflow job for this annotation

GitHub Actions / checks / checks

MD013

Line length 203 exceeds 80 characters

### `base/setup-runtime`

Expand All @@ -42,7 +42,8 @@
- Validates allowed `package-manager` values.
- For `bun`: installs Bun runtime.
- For `pnpm`/`npm`: installs Node.js.
- For `pnpm`: installs pnpm using `package.json#packageManager` when present, otherwise falls back to `latest`.

Check warning on line 45 in ACTIONS.md

View workflow job for this annotation

GitHub Actions / checks / checks

MD013

Line length 111 exceeds 80 characters
- Respects `HOLDEX_WORKING_DIR` env var for `package.json` detection when set.

### `base/prettier`

Expand All @@ -62,6 +63,7 @@
- Runs dependency install in repo context when `package.json` exists:
- `bun i --frozen-lockfile`, `pnpm install --frozen-lockfile`, or `npm ci`.
- Runs `prettier --check --ignore-unknown` on changed files.
- Respects `HOLDEX_WORKING_DIR` env var: all steps run in that directory when set.

### `base/markdown-check`

Expand All @@ -78,7 +80,8 @@
- Filters/uses markdown-only changed files.
- Skips execution if no markdown files changed.
- Installs `rumdl` globally using selected package manager.
- Runs `rumdl check --output-format github --fail-on error` on changed markdown files.

Check warning on line 83 in ACTIONS.md

View workflow job for this annotation

GitHub Actions / checks / checks

MD013

Line length 86 exceeds 80 characters
- Respects `HOLDEX_WORKING_DIR` env var: all steps run in that directory when set.

### `base/commit-check`

Expand All @@ -95,8 +98,9 @@
- Detects commitlint configuration from standard config files or `package.json`.
- If config exists, installs dependencies in repo context:
- `bun i --frozen-lockfile`, `pnpm install --frozen-lockfile`, or `npm ci`.
- If config does not exist, installs `@commitlint/config-conventional` and creates fallback `.commitlintrc.yml`.

Check warning on line 101 in ACTIONS.md

View workflow job for this annotation

GitHub Actions / checks / checks

MD013

Line length 112 exceeds 80 characters
- Validates PR title via `commitlint`.
- Respects `HOLDEX_WORKING_DIR` env var: all steps run in that directory when set.

## Composed Actions

Expand All @@ -114,6 +118,7 @@
- `run-markdown` (default: `"true"`): enable markdown check.
- `run-commits` (default: `"true"`): enable commit check.
- `package-manager` (default: `"bun"`): `bun`, `pnpm`, or `npm`.
- `working-directory` (default: `"."`): working directory to run all checks in.

#### Behavior

Expand All @@ -123,3 +128,36 @@
- `base/markdown-check`
- `base/commit-check`
- Assumes `base/setup-runtime` has already been called by the client.
- Sets `HOLDEX_WORKING_DIR` env var from `working-directory` input (falls back
to existing env var if already set by the calling workflow).

## Working Directory

All base actions and the `composed/pr-checks` action support running in a
subdirectory via the `HOLDEX_WORKING_DIR` environment variable.
This is useful for monorepos where checks should be scoped to a specific
package.

The env var is set automatically when using the `pr-checks.yml` reusable
workflow with the `working-directory` input, or when using
`composed/pr-checks` directly with the `working-directory` input.
Base actions read it implicitly — they require no additional inputs.

### Usage via reusable workflow

```yaml
jobs:
checks:
uses: holdex/github-actions/.github/workflows/pr-checks.yml@main
with:
working-directory: ./packages/my-package
```

### Usage via composed action

```yaml
- name: Run PR checks
uses: ./.holdex-actions/.github/actions/composed/pr-checks
with:
working-directory: ./packages/my-package
```
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
run-markdown: false
run-commits: true
package-manager: pnpm
working-directory: ./packages/my-package # optional, defaults to "."

- name: Run project checks
run: |
Expand Down Expand Up @@ -117,6 +118,16 @@ jobs:
package-manager: bun
```

Scoped to a subdirectory (e.g. monorepo):

```yaml
jobs:
checks:
uses: holdex/github-actions/.github/workflows/pr-checks.yml@<commit-sha>
with:
working-directory: ./packages/my-package
```

## Inputs and Behavior Reference

See [ACTIONS.md](ACTIONS.md) for workflow inputs and detailed behavior of each action.
Expand Down
Loading