Skip to content

feat(server): embed Pi SDK directly instead of CLI subprocess #622

feat(server): embed Pi SDK directly instead of CLI subprocess

feat(server): embed Pi SDK directly instead of CLI subprocess #622

name: API
on:
pull_request:
types: [labeled]
jobs:
autocommit:
name: auto-commit spec and client changes
runs-on: ubuntu-latest
if: github.event.label.name == 'autocommit-openapi'
timeout-minutes: 15
steps:
- name: Checkout repository
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.GH_PAT || secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Setup caches
uses: ./.github/actions/setup-caches
with:
cache-type: openapi-validation
os: ${{ runner.os }}
- name: Install Node.js dependencies
run: |
# Always install to avoid half-restored caches
npm ci --prefer-offline --no-audit
- name: Install intelligence-service dependencies
working-directory: server/intelligence-service
run: |
npm ci --no-audit --progress=false
- name: Setup Application Server directories
working-directory: server/application-server
run: |
mkdir -p ./keycloak-data
chmod -R 755 ./keycloak-data
- name: Compile Application Server
working-directory: server/application-server
run: mvn compile -DskipTests --quiet -Dmaven.build.cache.enabled=true
- name: Generate OpenAPI specs and clients
run: npm run generate:api
- name: Check for changes in the API
id: check_changes
run: |
echo "Checking for changes in the API client directory..."
echo "Current git status:"
git status
echo "Current git diff:"
git diff
git add .
echo "Git status after adding changes:"
git status
if git diff --cached --quiet; then
echo "No changes detected in the API client directory."
echo "no_changes_detected=true" >> $GITHUB_OUTPUT
else
echo "Changes detected in the API client directory."
echo "Staged changes:"
git diff --cached
echo "no_changes_detected=false" >> $GITHUB_OUTPUT
fi
- name: Commit files
if: ${{ always() && contains(github.event.pull_request.labels.*.name, 'autocommit-openapi') && steps.check_changes.outputs.no_changes_detected != 'true' }}
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') && steps.check_changes.outputs.no_changes_detected != 'true' }}
uses: ad-m/github-push-action@d91a481090679876dfc4178fef17f286781251df # v0.8.0
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
- name: Add PR comment with results
if: always()
run: |
if [[ "${{ steps.check_changes.outputs.no_changes_detected }}" == "true" ]]; then
COMMENT="🤖 No OpenAPI changes were needed - everything is already up to date."
else
COMMENT="🤖 OpenAPI specs and clients have been automatically updated and committed."
fi
curl -s -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/json" \
-d "{\"body\":\"$COMMENT\"}" \
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments"