Skip to content

Commit

Permalink
Merge pull request #294 from AvdLee/feature/update-api-spec-on-a-sche…
Browse files Browse the repository at this point in the history
…dule
  • Loading branch information
polpielladev authored Nov 26, 2024
2 parents 11b2fdf + 22a48ed commit e6cc949
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 11 deletions.
24 changes: 13 additions & 11 deletions .github/workflows/sync_asc_api.yml
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 }}

28 changes: 28 additions & 0 deletions check_for_updates.sh
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"

0 comments on commit e6cc949

Please sign in to comment.