Skip to content

Commit cf8ad2e

Browse files
committed
ci(update): act on new releases from bot octokit/openapi & octokit/types.ts, as well as workflow dispatch
1 parent d3c0e0a commit cf8ad2e

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

.github/workflows/update.yml

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,53 @@
11
name: Update
22
on:
33
repository_dispatch:
4-
types: [github-openapi-release]
4+
types:
5+
- octokit/openapi release
6+
- octokit/types.ts release
57

68
workflow_dispatch:
79
inputs:
810
version:
9-
description: "Version of https://www.npmjs.com/package/@github/openapi"
11+
description: "Version of https://www.npmjs.com/package/@octokit/openapi"
1012
required: true
1113

1214
jobs:
1315
update_routes:
1416
runs-on: ubuntu-latest
15-
if: github.event_name == 'workflow_dispatch' || github.event.client_payload.action == 'published'
1617
steps:
1718
- uses: actions/checkout@v2
1819
- uses: actions/setup-node@v1
1920
with:
2021
node-version: "12.x"
2122

22-
# try checking out routes-update branch. Ignore error if it does not exist
23+
# try checking out routes-update branch. Ignore error if it does not exist
2324
- run: git checkout routes-update || true
2425
- run: npm ci
2526
- run: rm -rf docs/
27+
28+
# if update is coming from octokit/openapi, use the version from event
2629
- run: npm run update-endpoints
27-
if: github.event_name == 'repository_dispatch'
30+
if: github.event_name == 'repository_dispatch' && github.event.event_type == 'octokit/openapi release'
2831
env:
2932
VERSION: ${{ github.event.client_payload.release.tag_name }}
33+
34+
# if event is workflow dispatch event, use version from input
3035
- run: npm run update-endpoints
3136
if: github.event_name == 'workflow_dispatch'
3237
env:
3338
VERSION: ${{ github.event.inputs.version }}
39+
40+
# if event is coming from octokit/types.ts, update @octokit/types to latest version and get OpenAPI version from its package.json
41+
- run: npm install @octokit/types@latest
42+
if: github.event_name == 'repository_dispatch' && github.event.event_type == 'octokit/types.ts release'
43+
- run: node -e "console.log('::set-output name=version::' + require('@octokit/types/package').octokit['openapi-version'])"
44+
if: github.event_name == 'repository_dispatch' && github.event.event_type == 'octokit/types.ts release'
45+
id: openapi_types
46+
- run: npm run update-endpoints
47+
if: github.event_name == 'workflow_dispatch'
48+
env:
49+
VERSION: ${{ steps.openapi_types.outputs.version }}
50+
3451
- name: Create Pull Request
3552
uses: gr2m/create-or-update-pull-request-action@v1.x
3653
env:

0 commit comments

Comments
 (0)