Skip to content

Commit 4a0529f

Browse files
authored
feat: add preview support for generating oas (#74)
* feat: add preview support for generating oas * use same action for checking out head * test * test
1 parent e2821aa commit 4a0529f

12 files changed

Lines changed: 20285 additions & 18 deletions

File tree

README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ and integration with docs platforms, see the [examples directory](./examples).
9696
9797
## Actions
9898
99-
This repository provides three GitHub actions.
99+
This repository provides four GitHub actions.
100100
101101
- `stainless-api/upload-openapi-spec-action/build`: Build SDKs for a Stainless
102102
project. This action is also usable in GitLab CI. For information about the
@@ -110,6 +110,11 @@ the [action definition](./preview/action.yml).
110110
a pull request. For information about the input parameters, see the [action
111111
definition](./merge/action.yml).
112112

113+
- `stainless-api/upload-openapi-spec-action/checkout-pr-ref`: Checkout the base
114+
or head commit for previewing a pull request's changes, saving changes to the
115+
config when needed. For information about the input parameters, see the [action
116+
definition](./checkout-pr-ref/action.yml).
117+
113118
### Workflow permissions
114119

115120
The GitHub actions use the following
@@ -120,14 +125,14 @@ will comment on the pull request with the build results. This is set to true by
120125
default. The actions use the `github_token` input to make a comment, and the
121126
comment must have the `pull-requests: write` permission.
122127

123-
- The `preview` action relies on being in a Git repository that can fetch from
124-
the remote to determine base revisions. This will be the case if you use the
125-
[`actions/checkout`](https://github.com/actions/checkout) GitHub action
126-
beforehand. That action needs the `contents: read` permission.
128+
- The `preview` and `checkout-pr-ref` actions rely on being in a Git repository
129+
that can fetch from the remote to determine base revisions. This will be the
130+
case if you use the [`actions/checkout`](https://github.com/actions/checkout)
131+
GitHub action beforehand. That action needs the `contents: read` permission.
127132

128133
### Versioning policy
129134

130-
This action uses [semantic versioning](https://semver.org/), and you can pin
135+
These actions use [semantic versioning](https://semver.org/), and you can pin
131136
your action to a major (`v1`), minor (`v1.0`), or patch (`v1.0.0`) version.
132137
The public API includes:
133138

checkout-pr-ref/action.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Stainless — Checkout PR ref
2+
description: Git checkout the base or head of a pull request
3+
runs:
4+
using: node20
5+
main: ../dist/checkoutPRRef.js
6+
inputs:
7+
ref:
8+
description: >-
9+
Which ref to checkout. Options: 'base', 'head'.
10+
required: true
11+
oas_path:
12+
description: Path to your OpenAPI spec.
13+
required: true
14+
config_path:
15+
description: >-
16+
Path to your Stainless config. Optional; only provide this if you are
17+
building or maintaining the ground truth Stainless config in your own
18+
repo.
19+
required: false
20+
21+
# We think it's unlikely you'll need to use non-default inputs for these:
22+
base_sha:
23+
description: >-
24+
The base SHA for the pull request. Used to create a base build.
25+
required: false
26+
default: ${{ github.event.pull_request.base.sha }}
27+
head_sha:
28+
description: >-
29+
The head SHA for the pull request. Used to get the OpenAPI spec and
30+
Stainless config for the preview build.
31+
required: false
32+
default: ${{ github.event.pull_request.head.sha }}

dist/build.js

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)