-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
41 additions
and
11 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,27 +27,26 @@ jobs: | |
cat release_info.json | ||
# Extract the download URL for the desired asset (example: 'my-asset.zip') | ||
ASSET_ID=$(jq -r '.assets[] | select(.name == "openapi-generator-cli.jar") | .id' release_info.json) | ||
ASSET_URL=$(jq -r '.assets[] | select(.name == "openapi-generator-cli.jar") | .browser_download_url' release_info.json) | ||
echo "Asset URL: $ASSET_ID" | ||
# Save asset URL for the next step | ||
echo "::set-output name=asset_id::$ASSET_URL" | ||
echo "::set-output name=asset_url::$ASSET_URL" | ||
- name: Download generator binary | ||
run: | | ||
REPO_OWNER="organization" | ||
REPO_NAME="another-repo" | ||
ASSET_ID=${{ steps.get_release.outputs.asset_id }} | ||
ASSET_URL=${{ steps.get_release.outputs.asset_url }} | ||
# Download the asset using the GitHub API | ||
curl -L -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
-H "Accept: application/octet-stream" \ | ||
-o tidalapi/bin/openapi-generator-cli.jar \ | ||
"$ASSET_ID" | ||
"$ASSET_URL" | ||
- name: Run the the TidalAPI code generation | ||
- name: Run the TidalAPI code generation | ||
run: | | ||
cd tidalapi | ||
chmod +x ./bin/openapi-generator-cli.jar | ||
|
@@ -56,28 +55,59 @@ jobs: | |
env: | ||
JAVA_HOME: /usr/lib/jvm/java-17-openjdk-amd64 | ||
|
||
- name: List changed files in directory | ||
id: check_changes | ||
env: | ||
DIRECTORY: "tidalapi/src/main/kotlin/com/tidal/sdk/tidalapi/generated" | ||
run: | | ||
CHANGED_FILES=$(git diff --name-only "${{ env.DIRECTORY }}") | ||
CHANGED_FILE_COUNT=$(echo "$CHANGED_FILES" | grep -v '^$' | wc -l) | ||
if [ "$CHANGED_FILE_COUNT" -eq 0 ]; then | ||
echo "No files changed in the specified directory." | ||
echo "::set-output name=changes_detected::false" | ||
else | ||
echo "Files changed in the specified directory:" | ||
echo "$CHANGED_FILES" | ||
echo "::set-output name=changes_detected::true" | ||
echo "::set-output name=changed_files::$CHANGED_FILES" | ||
echo "::set-output name=changed_file_count::$CHANGED_FILE_COUNT" | ||
fi | ||
- name: Commit changes | ||
if: steps.check_changes.outputs.changes_detected == 'true' | ||
run: | | ||
git config user.email "[email protected]" | ||
git config user.name "TIDAL Music Tools" | ||
git checkout -b tidal-music-tools/Update-Tidal-Api | ||
BRANCH_NAME="tidal-music-tools/Update-Tidal-Api" | ||
git checkout -b $BRANCH_NAME | ||
# Generate commit message with the number of changed files in the title and the list in the body | ||
COMMIT_TITLE="Add ${{ steps.check_changes.outputs.changed_file_count }} files via GitHub Actions" | ||
COMMIT_BODY="Changed files:\n${{ steps.check_changes.outputs.changed_files }}" | ||
git add . | ||
git commit -m "Add new files via GitHub Actions" | ||
git commit -m "$COMMIT_TITLE"$'\n\n'"$COMMIT_BODY" | ||
- name: Push changes | ||
if: steps.check_changes.outputs.changes_detected == 'true' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
git push origin tidal-music-tools/Update-Tidal-Api | ||
git push --set-upstream origin $BRANCH_NAME | ||
- name: Create Pull Request via API | ||
if: steps.check_changes.outputs.changes_detected == 'true' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
PR_DATA=$(jq -n --arg title "DO NOT REVIEW - Testing :-)" \ | ||
--arg head "new-feature-branch" \ | ||
PR_TITLE="Update Tidal API - ${steps.check_changes.outputs.changed_file_count} files changed" | ||
PR_BODY="This PR was created by GitHub Actions.\n\nChanged files:\n${{ steps.check_changes.outputs.changed_files }}" | ||
PR_DATA=$(jq -n --arg title "$PR_TITLE" \ | ||
--arg head "$BRANCH_NAME" \ | ||
--arg base "main" \ | ||
--arg body "This PR was created by GitHub Actions." \ | ||
--arg body "$PR_BODY" \ | ||
'{title: $title, head: $head, base: $base, body: $body}') | ||
curl -X POST \ | ||
|