Skip to content

Commit 5694672

Browse files
committed
docs: add README and CI workflow
1 parent a006ca2 commit 5694672

2 files changed

Lines changed: 168 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master, main]
6+
pull_request:
7+
branches: [master, main]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- uses: pnpm/action-setup@v4
16+
with:
17+
version: 9
18+
19+
- uses: actions/setup-node@v4
20+
with:
21+
node-version: 20
22+
cache: pnpm
23+
24+
# Clone the CLI repo for linked dependencies
25+
- name: Clone contractual CLI
26+
run: |
27+
git clone --depth 1 https://github.com/contractual-dev/contractual.git ../contractual
28+
29+
- name: Install dependencies
30+
run: pnpm install
31+
32+
- name: Build
33+
run: pnpm build
34+
35+
- name: Check dist is up to date
36+
run: |
37+
if [ -n "$(git status dist --porcelain)" ]; then
38+
echo "dist/ is out of date. Run 'pnpm build' and commit."
39+
exit 1
40+
fi
41+
42+
# test:
43+
# runs-on: ubuntu-latest
44+
# steps:
45+
# - uses: actions/checkout@v4
46+
# - uses: pnpm/action-setup@v4
47+
# with:
48+
# version: 9
49+
# - uses: actions/setup-node@v4
50+
# with:
51+
# node-version: 20
52+
# cache: pnpm
53+
# - run: pnpm install
54+
# - run: pnpm test

README.md

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Contractual GitHub Action
2+
3+
Schema contract lifecycle management for GitHub — lint, detect breaking changes, auto-generate changesets, and version contracts.
4+
5+
## Usage
6+
7+
```yaml
8+
- uses: contractual-dev/action@v1
9+
with:
10+
mode: pr-check
11+
github-token: ${{ secrets.GITHUB_TOKEN }}
12+
```
13+
14+
## Modes
15+
16+
### `pr-check`
17+
18+
Runs on pull requests. Detects breaking changes, posts a PR comment with a diff table, and auto-commits a changeset.
19+
20+
```yaml
21+
name: Contract Check
22+
23+
on:
24+
pull_request:
25+
paths:
26+
- 'specs/**'
27+
- 'schemas/**'
28+
29+
permissions:
30+
contents: write
31+
pull-requests: write
32+
33+
jobs:
34+
check:
35+
runs-on: ubuntu-latest
36+
steps:
37+
- uses: actions/checkout@v4
38+
with:
39+
fetch-depth: 0
40+
ref: ${{ github.head_ref }}
41+
42+
- uses: contractual-dev/action@v1
43+
with:
44+
mode: pr-check
45+
github-token: ${{ secrets.GITHUB_TOKEN }}
46+
```
47+
48+
### `release`
49+
50+
Runs on push to main. Consumes changesets and opens a "Version Contracts" PR.
51+
52+
```yaml
53+
name: Version Contracts
54+
55+
on:
56+
push:
57+
branches: [main]
58+
paths:
59+
- '.contractual/changesets/**'
60+
61+
permissions:
62+
contents: write
63+
pull-requests: write
64+
65+
jobs:
66+
release:
67+
runs-on: ubuntu-latest
68+
steps:
69+
- uses: actions/checkout@v4
70+
with:
71+
fetch-depth: 0
72+
73+
- uses: contractual-dev/action@v1
74+
with:
75+
mode: release
76+
github-token: ${{ secrets.GITHUB_TOKEN }}
77+
```
78+
79+
## Inputs
80+
81+
| Input | Required | Default | Description |
82+
|-------|----------|---------|-------------|
83+
| `mode` | Yes | — | `pr-check` or `release` |
84+
| `github-token` | No | `${{ github.token }}` | Token for PR comments and commits |
85+
| `fail-on-breaking` | No | `true` | Fail if breaking changes detected |
86+
| `auto-changeset` | No | `true` | Auto-generate changeset if missing |
87+
| `version-pr-title` | No | `Version Contracts` | Title of the Version PR |
88+
| `version-pr-branch` | No | `contractual/version-contracts` | Branch for the Version PR |
89+
| `anthropic-api-key` | No | — | Anthropic API key for AI features |
90+
91+
## Outputs
92+
93+
| Output | Mode | Description |
94+
|--------|------|-------------|
95+
| `has-breaking` | `pr-check` | `'true'` if breaking changes detected |
96+
| `has-changes` | `pr-check` | `'true'` if any spec changes detected |
97+
| `changeset-created` | `pr-check` | `'true'` if a changeset was committed |
98+
| `version-pr-url` | `release` | URL of the Version Contracts PR |
99+
100+
## Permissions
101+
102+
```yaml
103+
permissions:
104+
contents: write # Commit changesets and version bumps
105+
pull-requests: write # Post PR comments and create Version PR
106+
```
107+
108+
## Documentation
109+
110+
Full documentation at [contractual.dev](https://contractual.dev)
111+
112+
## License
113+
114+
MIT

0 commit comments

Comments
 (0)