-
Notifications
You must be signed in to change notification settings - Fork 1
76 lines (67 loc) · 2.23 KB
/
generate_on_pr.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: Generate SDK
on:
pull_request:
paths:
- .speakeasy/gen.yaml
types:
- opened
- synchronize
permissions:
contents: read
jobs:
# NOTE: This is a poor man's way of checking if the last commit was made by
# this workflow. If it was then we don't want to generate the SDK again.
should-generate:
runs-on:
- ubuntu-latest
outputs:
result: ${{ steps.decision.outputs.result }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.PAT }}
- id: decision
run: |
if [[ "$(git show -s --format=%B HEAD)" == "Update provider based on openapi.yaml changes" ]]; then
echo "result=false" >> "$GITHUB_OUTPUT"
else
echo "result=true" >> "$GITHUB_OUTPUT"
fi
generate:
needs:
- should-generate
permissions:
contents: write
runs-on:
- ubuntu-latest
if: needs.should-generate.outputs.result == 'true'
steps:
- name: Install Speakeasy
uses: mheap/setup-go-cli@fa9b01cdd4115eac636164f0de43bf7d51c82697 # v1.2.2
with:
owner: speakeasy-api
repo: speakeasy
cli_name: speakeasy
package_type: zip
version: 1.494.0 # renovate: datasource=github-releases depName=speakeasy-api/speakeasy
- name: Checkout current repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.PAT }}
- name: Configure speakeasy CLI
run: |
mkdir -p ~/.speakeasy
echo 'speakeasy_api_key: ${{ secrets.SPEAKEASY_API_KEY }}' > ~/.speakeasy/config.yaml
- uses: jdx/mise-action@5083fe46898c414b2475087cc79da59e7da859e8 # v2.1.11
with:
install: false
- name: Generate SDK
run: make generate.sdk
- name: Commit SDK changes to the PR
uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4
with:
add: .
default_author: github_actor
message: Update provider based on openapi.yaml changes