-
-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #294 from AvdLee/feature/update-api-spec-on-a-sche…
…dule
- Loading branch information
Showing
2 changed files
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 |
---|---|---|
@@ -1,22 +1,24 @@ | ||
name: Synchronize ASC API | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
branches: [ main ] | ||
schedule: | ||
# run once per day | ||
- cron: '0 12 * * *' | ||
- cron: '0 * * * *' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
diff_spec: | ||
runs-on: macos-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: make download | ||
|
||
# If there are any differences, this step will fail | ||
# and issue a notification. The api will then need to be | ||
# updated and tagged manually. | ||
- run: git diff --ignore-all-space --exit-code | ||
- run: ./check_for_updates.sh | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
|
||
echo "Checking for updates..." | ||
|
||
CURRENT_VERSION=$(cat Sources/OpenAPI/app_store_connect_api.json | jq -r '.info.version') | ||
|
||
make download | ||
|
||
NEW_VERSION=$(cat Sources/OpenAPI/app_store_connect_api.json | jq -r '.info.version') | ||
REMOTE_BRANCH=$(git ls-remote origin refs/heads/spec-update-$NEW_VERSION) | ||
|
||
echo "Current version: $CURRENT_VERSION" | ||
echo "New version: $NEW_VERSION" | ||
echo "Remote branch: $REMOTE_BRANCH" | ||
if [ "$NEW_VERSION" == "$CURRENT_VERSION" ] || [ ! -z $REMOTE_BRANCH ] ; then | ||
echo "Spec version is up to date" | ||
exit 0 | ||
fi | ||
|
||
make generate | ||
|
||
git config --local user.name "App Store Connect Swift SDK CI" | ||
git switch --create spec-update-$NEW_VERSION | ||
git add --all | ||
git commit -m "[ci skip] Update spec to $NEW_VERSION" | ||
git push -u origin spec-update-$NEW_VERSION | ||
create_pr_output=$(gh pr create --title "Update OpenAPI spec to $NEW_VERSION" --body "$warnings") | ||
echo "Pull request created: $create_pr_output" |