|
1 | 1 | name: Update |
2 | 2 | on: |
3 | 3 | repository_dispatch: |
4 | | - types: [github-openapi-release] |
| 4 | + types: |
| 5 | + - octokit/openapi release |
| 6 | + - octokit/types.ts release |
5 | 7 |
|
6 | 8 | workflow_dispatch: |
7 | 9 | inputs: |
8 | 10 | version: |
9 | | - description: "Version of https://www.npmjs.com/package/@github/openapi" |
| 11 | + description: "Version of https://www.npmjs.com/package/@octokit/openapi" |
10 | 12 | required: true |
11 | 13 |
|
12 | 14 | jobs: |
13 | 15 | update_routes: |
14 | 16 | runs-on: ubuntu-latest |
15 | | - if: github.event_name == 'workflow_dispatch' || github.event.client_payload.action == 'published' |
16 | 17 | steps: |
17 | 18 | - uses: actions/checkout@v2 |
18 | 19 | - uses: actions/setup-node@v1 |
19 | 20 | with: |
20 | 21 | node-version: "12.x" |
21 | 22 |
|
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 |
23 | 24 | - run: git checkout routes-update || true |
24 | 25 | - run: npm ci |
25 | 26 | - run: rm -rf docs/ |
| 27 | + |
| 28 | + # if update is coming from octokit/openapi, use the version from event |
26 | 29 | - 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' |
28 | 31 | env: |
29 | 32 | VERSION: ${{ github.event.client_payload.release.tag_name }} |
| 33 | + |
| 34 | + # if event is workflow dispatch event, use version from input |
30 | 35 | - run: npm run update-endpoints |
31 | 36 | if: github.event_name == 'workflow_dispatch' |
32 | 37 | env: |
33 | 38 | 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 | + |
34 | 51 | - name: Create Pull Request |
35 | 52 | uses: gr2m/create-or-update-pull-request-action@v1.x |
36 | 53 | env: |
|
0 commit comments