-
Notifications
You must be signed in to change notification settings - Fork 60
58 lines (44 loc) · 1.55 KB
/
convert-examples-to-json.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
name: convert-examples-to-json
# author: @MikeRalphson / @cebe
# issue: https://github.com/OAI/OpenAPI-Specification/issues/1385
#
# This workflow updates the *.json files in the examples/v3.x directories,
# when the corresponding *.yaml files change.
# JSON example files are automatically generated from the YAML example files.
# Only the YAML files should be adjusted manually.
#
# run this on push to main
on:
push:
branches:
- main
paths:
- 'examples/**'
jobs:
yaml2json:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2 # checkout repo content
- uses: actions/setup-node@v4 # setup Node.js
with:
node-version: '20.x'
- name: Install dependencies
run: npm ci
- name: convert YAML examples to JSON
run: find examples/v3* -type f -name "*.yaml" | xargs node scripts/yaml2json/yaml2json.js
- name: pretty-print JSON examples
run: npx prettier --write examples/**/*.json
- name: git diff
run: |
git add examples/**/*.json
git --no-pager -c color.diff=always diff --staged
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: update-json-examples
title: Update JSON example files
commit-message: Update JSON example files
body: |
This pull request is automatically triggered by GitHub action `convert-examples-to-json`.
The examples/v3.* YAML files have changed, so the JSON files are automatically being recreated.