Skip to content

Automatic Greeting Feature #304

Automatic Greeting Feature

Automatic Greeting Feature #304

name: OpenAPI
on:
pull_request:
types: [opened, synchronize, labeled, reopened]
paths:
- 'server/application-server/**'
- '.github/workflows/generate-application-server-client.yml'
push:
paths:
- 'server/application-server/openapi.yaml'
- 'webapp/src/app/core/modules/openapi/**'
branches: [develop]
workflow_dispatch:
jobs:
generate-api-client:
name: Verify API Specs and Client of the Application Server (add autocommit-openapi label to PR to auto-commit changes)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Set up directories
working-directory: server/application-server
run: |
mkdir -p ./keycloak-data
chmod -R 755 ./keycloak-data
- name: Install dependencies
run: npm install
- name: Generate API client for the application server
run: npm run generate:api:application-server
- name: Check for changes in the API
id: check_changes
run: |
echo "Checking for changes in the API client directory..."
git add .
if git diff --cached --quiet; then
echo "No changes detected in the API client directory."
echo "NO_CHANGES_DETECTED=true" >> $GITHUB_ENV
else
echo "Changes detected in the API client directory."
echo "NO_CHANGES_DETECTED=false" >> $GITHUB_ENV
exit 1
fi
- name: Commit files
if: ${{ always() && contains(github.event.pull_request.labels.*.name, 'autocommit-openapi') }}
run: |
echo "Committing and pushing changes..."
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git commit -a -m "chore: update API specs and client"
- name: Push changes
if: ${{ always() && contains(github.event.pull_request.labels.*.name, 'autocommit-openapi') }}
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GH_PAT }}
branch: ${{ github.event.pull_request.head.ref }}
- name: Remove autocommit-openapi label
if: ${{ always() && contains(github.event.pull_request.labels.*.name, 'autocommit-openapi') }}
run: |
echo "Removing the autocommit-openapi label..."
curl --silent --fail-with-body -X DELETE -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels/autocommit-openapi