1+ # This workflow is provided via the organization template repository
2+ #
3+ # https://github.com/nextcloud/.github
4+ # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
5+ #
6+ # SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
7+ # SPDX-FileCopyrightText: 2024 Arthur Schiwon <blizzz@arthur-schiwon.de>
8+ # SPDX-License-Identifier: MIT
9+
110name : OpenAPI
211
312on : pull_request
@@ -13,22 +22,75 @@ jobs:
1322 openapi :
1423 runs-on : ubuntu-latest
1524
25+ if : ${{ github.repository_owner != 'nextcloud-gmbh' }}
26+
1627 steps :
1728 - name : Checkout
1829 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
1930 with :
2031 persist-credentials : false
2132
33+ - name : Get php version
34+ id : php_versions
35+ uses : icewind1991/nextcloud-version-matrix@8a7bac6300b2f0f3100088b297995a229558ddba # v1.3.2
36+
2237 - name : Set up php
23- uses : shivammathur/setup-php@20529878ed81ef8e78ddf08b480401e6101a850f # v2
38+ uses : shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # 2.37.1
2439 with :
25- php-version : ' 8.1'
26- # https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation
27- extensions : bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib
40+ php-version : ${{ steps.php_versions.outputs.php-available }}
41+ extensions : xml
2842 coverage : none
2943 ini-file : development
3044 env :
3145 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
3246
33- - name : Build using Makefile
34- run : make openapi-spec
47+ - name : Check Typescript OpenApi types
48+ id : check_typescript_openapi
49+ uses : andstor/file-existence-action@558493d6c74bf472d87c84eab196434afc2fa029 # v3.1.0
50+ with :
51+ files : " src/types/openapi/openapi*.ts"
52+
53+ - name : Read package.json node and npm engines version
54+ if : steps.check_typescript_openapi.outputs.files_exists == 'true'
55+ uses : skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3
56+ id : node_versions
57+ # Continue if no package.json
58+ continue-on-error : true
59+ with :
60+ fallbackNode : ' ^24'
61+ fallbackNpm : ' ^11.3'
62+
63+ - name : Set up node ${{ steps.node_versions.outputs.nodeVersion }}
64+ if : ${{ steps.node_versions.outputs.nodeVersion }}
65+ uses : actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
66+ with :
67+ node-version : ${{ steps.node_versions.outputs.nodeVersion }}
68+
69+ - name : Set up npm ${{ steps.node_versions.outputs.npmVersion }}
70+ if : ${{ steps.node_versions.outputs.nodeVersion }}
71+ run : npm i -g 'npm@${{ steps.node_versions.outputs.npmVersion }}'
72+
73+ - name : Install dependencies
74+ if : ${{ steps.node_versions.outputs.nodeVersion }}
75+ env :
76+ CYPRESS_INSTALL_BINARY : 0
77+ PUPPETEER_SKIP_DOWNLOAD : true
78+ run : |
79+ npm ci
80+
81+ - name : Set up dependencies
82+ run : composer i
83+
84+ - name : Regenerate OpenAPI
85+ run : composer run openapi
86+
87+ - name : Check openapi*.json and typescript changes
88+ run : |
89+ bash -c "[[ ! \"`git status --porcelain `\" ]] || (echo 'Please run \"composer run openapi\" and commit the openapi*.json files and (if applicable) src/types/openapi/openapi*.ts, see the section \"Show changes on failure\" for details' && exit 1)"
90+
91+ - name : Show changes on failure
92+ if : failure()
93+ run : |
94+ git status
95+ git --no-pager diff
96+ exit 1 # make it red to grab attention
0 commit comments