Update backend api spec generated by Kotlin Gradle Plugin #2457
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: Update backend api spec generated by Kotlin Gradle Plugin | |
on: | |
schedule: | |
# triggers the workflow every day at 5:30 UTC | |
- cron: '30 5 * * *' | |
workflow_dispatch: | |
jobs: | |
update_backend_api_spec: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: peterjgrainger/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
branch: 'infra/update-backend-api-spec' | |
- uses: actions/checkout@v4 | |
with: | |
ref: 'infra/update-backend-api-spec' | |
fetch-depth: 0 # we need a full history to make rebase with master | |
- name: Set up Java | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 17 | |
distribution: temurin | |
- name: Set up Git | |
run: | | |
git config user.name github-actions[bot] | |
git config user.email 'github-actions[bot]@users.noreply.github.com' | |
- name: Update branch from master | |
run: | | |
git pull origin master --no-edit --rebase | |
# we need save-cli.kexe to start backend, because InternalFileStorage requires it when save-cli has -SNAPSHOT version | |
- name: Mock save-cli | |
if: ${{ endsWith(needs.build_cli.outputs.version, '-SNAPSHOT') }} | |
run: | | |
mkdir ${{ github.workspace }}/save-cli | |
touch ${{ github.workspace }}/save-cli/save-cli.kexe | |
echo SAVE_CLI_GRADLE_OPTS=-PsaveCliPath=${{ github.workspace }}/save-cli >> $GITHUB_ENV | |
- name: Generate open api doc | |
uses: gradle/gradle-build-action@v3 | |
with: | |
gradle-version: wrapper | |
arguments: | | |
:save-backend:generateOpenApiDocs | |
${{ env.SAVE_CLI_GRADLE_OPTS || '' }} | |
-PgprUser=${{ github.actor }} | |
-PgprKey=${{ secrets.GITHUB_TOKEN }} | |
- name: Commit and push if api spec is changed | |
id: commit-and-push | |
run: | | |
git add save-backend/backend-api-docs.json | |
if git diff --staged --quiet; then | |
echo Everything is UP-TO-DATE | |
else | |
echo Pushing updated backend-api-docs.json | |
git commit -m "Update backend-api-docs.json" | |
git push | |
echo "SHOULD_CREATE_PR=1" >> $GITHUB_OUTPUT | |
fi | |
- name: Create Pull Request | |
if: ${{ startsWith(steps.commit-and-push.outputs.SHOULD_CREATE_PR, '1') }} | |
run: | | |
gh pr create -B master -H infra/update-backend-api-spec \ | |
--title '[Open API] New version of backend api spec' \ | |
--body 'Update backend api spec [auto-generated]' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |