Weekly AI Core specification file update #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Weekly AI Core specification file update" | |
# Every Sunday at 00:00 | |
on: | |
schedule: | |
- cron: "0 0 * * 0" | |
# also manually triggered | |
workflow_dispatch: | |
env: | |
MVN_MULTI_THREADED_ARGS: --batch-mode --no-transfer-progress --fail-at-end --show-version --threads 1C | |
SPECIFICATION_FILE_PATH: "core/src/main/resources/spec/aicore.yaml" | |
GENERATED_CLIENT_PATH: "core/src/main/java/com/sap/ai/sdk/core/client" | |
# https://cli.github.com/manual/gh_help_environment used for creating the pull request | |
GH_PUBLIC_TOKEN: ${{ secrets.PUBLIC_GITHUB_TOKEN }} | |
ASA1FINCLOUDOPER_WDF_TOKEN: ${{ secrets.ASA1FINCLOUDOPER_WDF_TOKEN }} | |
JAVA_VERSION: 17 | |
MAVEN_VERSION: 3.9.8 | |
jobs: | |
update-aicore-specification: | |
name: "Update AI Core specification" | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Checkout repository" | |
uses: actions/checkout@v4 | |
- name: "Configure git" | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "SAP Cloud SDK Bot" | |
- name: "Clone AI Core API repository" | |
run: | | |
git clone https://${{ env.ASA1FINCLOUDOPER_WDF_TOKEN }}@github.wdf.sap.corp/AI/apis.git | |
- name: "Copy AI Core specification file" | |
run: | | |
cp apis/aicore.yaml $SPECIFICATION_FILE_PATH | |
cat $SPECIFICATION_FILE_PATH | |
- name: "Exit if there are no changes" | |
run: | | |
! git diff --exit-code | |
- name: "Create branch" | |
run: | | |
git checkout -b update-aicore-specification | |
- name: "Commit specification file" | |
run: | | |
git add $SPECIFICATION_FILE_PATH | |
git commit -m "Update AI Core specification" | |
cat $SPECIFICATION_FILE_PATH | |
- name: "Push changes" | |
run: | | |
git push origin update-aicore-specification | |
create-pull-request: | |
name: "Create pull request" | |
runs-on: ubuntu-latest | |
needs: update-aicore-specification | |
steps: | |
- name: "Checkout repository" | |
uses: actions/checkout@v4 | |
- name: "Create pull request" | |
run: | | |
gh pr create --base main --head update-aicore-specification --title "Update AI Core specification" --body " | |
The AI Core [specification](https://github.wdf.sap.corp/AI/apis/blob/master/aicore.yaml) was updated | [release notes](https://github.wdf.sap.corp/AI/apis/blob/master/ai_api.changelog.txt) | |
Fixes were also automatically applied to the specification." | |
- name: "Handle failure" | |
if: ${{ failure() }} | |
run: | | |
git push origin --delete update-aicore-specification | |
generate-client: | |
name: "Generate AI Core client and push" | |
runs-on: ubuntu-latest | |
needs: create-pull-request | |
steps: | |
- name: "Checkout repository" | |
uses: actions/checkout@v4 | |
with: | |
ref: update-aicore-specification | |
- name: "Setup java" | |
uses: actions/setup-java@v4 | |
with: | |
distribution: "temurin" | |
java-version: ${{ env.JAVA_VERSION }} | |
cache: 'maven' | |
- name: "Re-generate AI Core client" | |
run: | | |
rm -rf $GENERATED_CLIENT_PATH | |
mvn clean install -pl core -DskipTests ${{ env.MVN_MULTI_THREADED_ARGS }} | |
- name: "Commit generated client" | |
run: | | |
git add $GENERATED_CLIENT_PATH | |
git commit -m "Update AI Core client" | |
- name: "Push changes" | |
run: | | |
git push origin update-aicore-specification |