|
| 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 | + |
| 10 | +name: OpenAPI |
| 11 | + |
| 12 | +on: pull_request |
| 13 | + |
| 14 | +permissions: |
| 15 | + contents: read |
| 16 | + |
| 17 | +concurrency: |
| 18 | + group: openapi-${{ github.head_ref || github.run_id }} |
| 19 | + cancel-in-progress: true |
| 20 | + |
| 21 | +jobs: |
| 22 | + openapi: |
| 23 | + runs-on: ubuntu-latest |
| 24 | + |
| 25 | + if: ${{ github.repository_owner != 'nextcloud-gmbh' }} |
| 26 | + |
| 27 | + steps: |
| 28 | + - name: Checkout |
| 29 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 30 | + with: |
| 31 | + persist-credentials: false |
| 32 | + |
| 33 | + - name: Get php version |
| 34 | + id: php_versions |
| 35 | + uses: icewind1991/nextcloud-version-matrix@58becf3b4bb6dc6cef677b15e2fd8e7d48c0908f # v1.3.1 |
| 36 | + |
| 37 | + - name: Set up php |
| 38 | + uses: shivammathur/setup-php@ec406be512d7077f68eed36e63f4d91bc006edc4 # v2.35.4 |
| 39 | + with: |
| 40 | + php-version: ${{ steps.php_versions.outputs.php-available }} |
| 41 | + extensions: xml |
| 42 | + coverage: none |
| 43 | + ini-file: development |
| 44 | + env: |
| 45 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 46 | + |
| 47 | + - name: Check Typescript OpenApi types |
| 48 | + id: check_typescript_openapi |
| 49 | + uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.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: '^20' |
| 61 | + fallbackNpm: '^10' |
| 62 | + |
| 63 | + - name: Set up node ${{ steps.node_versions.outputs.nodeVersion }} |
| 64 | + if: ${{ steps.node_versions.outputs.nodeVersion }} |
| 65 | + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.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