Skip to content

ci(actions): Update workflows #454

ci(actions): Update workflows

ci(actions): Update workflows #454

# This workflow is provided via the organization template repository
#
# https://github.com/nextcloud/.github
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
#
# SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: MIT
name: Generate OpenAPI in Repositories
on:
pull_request:
push:
branches:
- main
- master
- stable*
permissions:
contents: read
concurrency:
group: openapi-repositories-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
openapi-repositories:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-versions: [ "8.3" ]
repositories:
- "nextcloud/app_template"
- "nextcloud/approve_links"
- "nextcloud/assistant"
- "nextcloud/files_retention"
- "nextcloud/forms"
- "nextcloud/groupfolders"
- "nextcloud/mail"
- "nextcloud/notifications"
- "nextcloud/password_policy"
- "nextcloud/recommendations"
- "nextcloud/server"
- "nextcloud/spreed"
- "nextcloud/tables"
- "nextcloud/terms_of_service"
name: openapi-repositories
steps:
- name: Checkout
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
persist-credentials: false
- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2.36.0
with:
php-version: ${{ matrix.php-versions }}
coverage: none
ini-file: development
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout repository for testing
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
persist-credentials: false
repository: ${{ matrix.repositories }}
path: temp-repository
- name: Install dependencies
run: composer i
- name: Generate OpenAPI
if: matrix.repositories != 'nextcloud/server'
working-directory: temp-repository/
run: ../bin/generate-spec
- name: Generate OpenAPI - Server
if: matrix.repositories == 'nextcloud/server'
working-directory: temp-repository/
run: |
specs=()
for path in core apps/*; do
if [ ! -f "$path/.noopenapi" ]; then
../bin/generate-spec "$path" "$path/openapi.json" || exit 1
if [[ "$(basename "$path")" != "core" ]]; then
if [ -f "$path/openapi-full.json" ]; then
specs+=("$path/openapi-full.json")
else
specs+=("$path/openapi.json")
fi
fi
fi
done
../bin/merge-specs \
--core core/openapi-full.json \
--merged openapi.json \
"${specs[@]}"
- name: Show changes of the API for assistance
working-directory: temp-repository/
run: |
git status
git --no-pager diff
summary:
permissions:
contents: none
runs-on: ubuntu-latest-low
needs: openapi-repositories
if: always()
name: openapi-repositories-summary
steps:
- name: Summary status
run: if ${{ needs.openapi-repositories.result != 'success' && needs.openapi-repositories.result != 'skipped' }}; then exit 1; fi