|
4 | 4 | schedule: |
5 | 5 | - cron: "0 0 * * *" |
6 | 6 | workflow_dispatch: |
| 7 | + pull_request: |
7 | 8 |
|
8 | 9 | jobs: |
9 | 10 | build: |
10 | 11 | runs-on: ubuntu-latest |
11 | 12 | steps: |
12 | | - - uses: actions/checkout@v2.3.4 |
13 | | - with: |
14 | | - ref: 'master' |
15 | | - |
16 | | - - name: Download OpenAPI file |
17 | | - run: curl -s https://api.jellyfin.org/openapi/jellyfin-openapi-stable.json > openapi.json |
18 | | - |
19 | | - - name: Modify the schema |
20 | | - run: node scripts/modifySchema.mjs openapi.json |
| 13 | + - uses: actions/checkout@v2.3.4 |
21 | 14 |
|
22 | | - - name: Generate |
23 | | - uses: docker://openapitools/openapi-generator-cli:latest-release |
24 | | - env: |
25 | | - TS_POST_PROCESS_FILE: true |
26 | | - with: |
27 | | - args: >- |
28 | | - generate -i /github/workspace/openapi.json |
29 | | - -g typescript-axios --additional-properties=npmName=@jellyfin/client-axios |
30 | | - --additional-properties=npmRepository=https://www.npmjs.com/package/@jellyfin/client-axios |
31 | | - --additional-properties=supportsES6=true |
32 | | - --additional-properties=useSingleRequestParameter=true |
33 | | - --additional-properties=withSeparateModelsAndApi=true |
34 | | - --additional-properties=modelPackage=models |
35 | | - --additional-properties=apiPackage=api |
36 | | - --enable-post-process-file |
37 | | - -o /github/workspace/stable |
| 15 | + - name: Download OpenAPI file |
| 16 | + run: curl -s https://api.jellyfin.org/openapi/jellyfin-openapi-stable.json > openapi.json |
38 | 17 |
|
39 | | - - name: Check if .ts files were modified |
40 | | - id: diff |
41 | | - run: echo "::set-output name=count::$(git status -s | grep ts | wc -l)" |
| 18 | + - name: Modify the schema |
| 19 | + run: node scripts/modifySchema.mjs openapi.json |
42 | 20 |
|
43 | | - - name: Get OpenApi version |
44 | | - if: ${{ steps.diff.outputs.count }} > 0 |
45 | | - id: version |
46 | | - run: echo "::set-output name=number::$(cat openapi.json | jq '.info.version')" |
| 21 | + - name: Generate |
| 22 | + uses: docker://openapitools/openapi-generator-cli:latest-release |
| 23 | + env: |
| 24 | + TS_POST_PROCESS_FILE: true |
| 25 | + with: |
| 26 | + args: >- |
| 27 | + generate -i /github/workspace/openapi.json |
| 28 | + -g typescript-axios --additional-properties=npmName=@jellyfin/client-axios |
| 29 | + --additional-properties=npmRepository=https://www.npmjs.com/package/@jellyfin/client-axios |
| 30 | + --additional-properties=supportsES6=true |
| 31 | + --additional-properties=useSingleRequestParameter=true |
| 32 | + --additional-properties=withSeparateModelsAndApi=true |
| 33 | + --additional-properties=modelPackage=models |
| 34 | + --additional-properties=apiPackage=api |
| 35 | + --enable-post-process-file |
| 36 | + -o /github/workspace/stable |
47 | 37 |
|
48 | | - - name: Set version in package.json |
49 | | - if: ${{ steps.diff.outputs.count }} > 0 |
50 | | - run: | |
51 | | - echo "$(cat stable/package.json | jq '.version = ${{ steps.version.outputs.number }}')" > stable/package.json |
52 | | - echo "$(cat stable/package-lock.json | jq '.version = ${{ steps.version.outputs.number }}')" > stable/package-lock.json |
| 38 | + - name: Check if .ts files were modified |
| 39 | + id: diff |
| 40 | + run: echo "::set-output name=count::$(git status -s | grep ts | wc -l)" |
53 | 41 |
|
54 | | - - name: Setup node environment |
55 | | - if: ${{ steps.diff.outputs.count }} > 0 |
56 | | - uses: actions/setup-node@v2.4.0 |
57 | | - with: |
58 | | - node-version: 14 |
59 | | - cache: 'npm' |
60 | | - cache-dependency-path: | |
61 | | - stable/package-lock.json |
62 | | - unstable/package-lock.json |
| 42 | + - name: Get OpenApi version |
| 43 | + if: ${{ steps.diff.outputs.count }} > 0 |
| 44 | + id: version |
| 45 | + run: echo "::set-output name=number::$(cat openapi.json | jq '.info.version')" |
63 | 46 |
|
64 | | - - name: Install dependencies |
65 | | - if: ${{ steps.diff.outputs.count }} > 0 |
66 | | - run: npm ci --no-audit |
67 | | - working-directory: ./stable |
| 47 | + - name: Set version in package.json |
| 48 | + if: ${{ steps.diff.outputs.count }} > 0 |
| 49 | + run: | |
| 50 | + echo "$(cat stable/package.json | jq '.version = ${{ steps.version.outputs.number }}')" > stable/package.json |
| 51 | + echo "$(cat stable/package-lock.json | jq '.version = ${{ steps.version.outputs.number }}')" > stable/package-lock.json |
68 | 52 |
|
69 | | - - name: Build |
70 | | - if: ${{ steps.diff.outputs.count }} > 0 |
71 | | - run: npm run build |
72 | | - working-directory: ./stable |
| 53 | + - name: Setup node environment |
| 54 | + if: ${{ steps.diff.outputs.count }} > 0 |
| 55 | + uses: actions/setup-node@v2.4.0 |
| 56 | + with: |
| 57 | + node-version: 14 |
| 58 | + cache: "npm" |
| 59 | + cache-dependency-path: stable/package-lock.json |
73 | 60 |
|
74 | | - # "echo" in commit returns true so the build succeeds, even if no changed files |
75 | | - - name: Commit new changes to the repo |
76 | | - if: ${{ steps.diff.outputs.count }} > 0 |
77 | | - run: | |
78 | | - git config --global user.email "packaging@jellyfin.org" |
79 | | - git config --global user.name "Jellyfin Packaging Team" |
80 | | - git pull |
81 | | - git add . |
82 | | - git commit -m "Update stable OpenAPI client" || echo |
83 | | - git push |
| 61 | + - name: Install dependencies |
| 62 | + if: ${{ steps.diff.outputs.count }} > 0 |
| 63 | + run: npm ci --no-audit |
| 64 | + working-directory: ./stable |
| 65 | + |
| 66 | + - name: Build |
| 67 | + if: ${{ steps.diff.outputs.count }} > 0 |
| 68 | + run: npm run build |
| 69 | + working-directory: ./stable |
| 70 | + |
| 71 | + # "echo" in commit returns true so the build succeeds, even if no changed files |
| 72 | + - name: Commit new changes to the repo |
| 73 | + if: ${{ steps.diff.outputs.count }} > 0 && github.event_name != 'pull_request' |
| 74 | + run: | |
| 75 | + git config --global user.email "packaging@jellyfin.org" |
| 76 | + git config --global user.name "Jellyfin Packaging Team" |
| 77 | + git pull |
| 78 | + git add . |
| 79 | + git commit -m "Update stable OpenAPI client" || echo |
| 80 | + git push |
0 commit comments