Skip to content

Update OpenAPI definition #862

Update OpenAPI definition

Update OpenAPI definition #862

name: Update OpenAPI definition
on:
schedule:
# runs every day at 02:02 UTC
- cron: '2 2 * * *'
workflow_dispatch:
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup java
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
cache: 'maven'
- name: Build tools
run: ./mvnw -B package -Pcli --projects spotify-web-api-open-api --also-make
- name: Download Spotify's OpenAPI
run: wget -O official-spotify-open-api.yml https://developer.spotify.com/_data/documentation/web-api/reference/open-api-schema.yml
- name: Patch Spotify's OpenAPI
run: ./scripts/patch-open-api.sh
- name: Create Pull Request
if: success() || failure()
id: cpr
uses: peter-evans/create-pull-request@v6
with:
# Use a PAT so GitHub actions are triggered on the PR
token: ${{ secrets.GH_REPO_TOKEN }}
commit-message: "Automated update of Spotify's OpenAPI definition"
branch: 'spotify-openapi-update'
delete-branch: true
base: main
title: "Update of Spotify's OpenAPI definition"
body: |
Automated update of Spotify's OpenAPI definition
Generated by [this workflow run](https://github.com/sonallux/spotify-web-api/actions/runs/${{ github.run_id }}).
- name: Comment on PR
if: (success() || failure()) && steps.cpr.outputs.pull-request-operation == 'created'
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.createComment({
issue_number: ${{ steps.cpr.outputs.pull-request-number }},
owner: context.repo.owner,
repo: context.repo.repo,
body: "@sonallux Spotify's OpenAPI definition has been updated!"
})