Update Wrapper #736
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 Wrapper | |
on: | |
schedule: | |
# runs every day at 02:23 UTC | |
- cron: '23 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: Get latest fixed open api definition | |
id: latest-openapi | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
result-encoding: string | |
script: | | |
const response = await github.rest.repos.getLatestRelease({ | |
owner: 'sonallux', | |
repo: 'spotify-web-api', | |
}); | |
const assetName = 'fixed-spotify-open-api.yml'; | |
const asset = response.data.assets.find(asset => asset.name === assetName); | |
const browserDownloadUrl = asset?.browser_download_url; | |
if (!browserDownloadUrl) { | |
core.setFailed('Latest release did not contain the correct asset!'); | |
} | |
return browserDownloadUrl; | |
- name: Download Spotify's OpenAPI | |
run: wget -O spotify-web-api-java-generator/fixed-spotify-open-api.yml ${{ steps.latest-openapi.outputs.result }} | |
- name: Build generator | |
run: ./mvnw -B -DskipTests package -Pcli | |
- name: Generate Java wrapper | |
run: ./generate-java-wrapper.sh | |
- name: Create Pull Request | |
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 fixed-spotify-open-api.yml' | |
branch: 'openapi-update' | |
delete-branch: true | |
base: main | |
title: 'Automated update of `fixed-spotify-open-api.yml`' | |
body: | | |
Automated update of `fixed-spotify-open-api.yml` | |
Generated by [this workflow run](https://github.com/sonallux/spotify-web-api-java/actions/runs/${{ github.run_id }}). | |
- name: Check outputs | |
run: 'echo "Pull Request ${{ steps.cpr.outputs.pull-request-operation }}: ${{ steps.cpr.outputs.pull-request-url }}"' | |
- name: Comment on PR | |
if: 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 fixed-spotify-open-api.yml has been updated!" | |
}) |