Skip to content

Commit 59b496d

Browse files
committed
ci: only commit if there are changes
1 parent 098681d commit 59b496d

1 file changed

Lines changed: 39 additions & 31 deletions

File tree

.github/workflows/create-release-pr.yml

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ jobs:
7676
ref: ${{ needs.prep.outputs.release_branch }}
7777
token: ${{ secrets.GH_PUSH_TOKEN || github.token }}
7878

79+
- name: Setup Git User
80+
uses: OneSignal/sdk-actions/.github/actions/setup-git-user@main
81+
7982
- name: Setup Bun
8083
uses: oven-sh/setup-bun@v2
8184
with:
@@ -114,20 +117,24 @@ jobs:
114117
RELEASE=$(curl -s -H "Authorization: token ${{ github.token }}" \
115118
"https://api.github.com/repos/OneSignal/OneSignal-Android-SDK/releases/tags/${VERSION}")
116119
117-
if sed -n '/\"id\"/p' <<< "$RELEASE" | grep -q .; then
118-
# Update plugin.xml with new version
119-
# mac os sed syntax
120-
sed -i '' 's|<framework src="com\.onesignal:OneSignal:[^"]*" />|<framework src="com.onesignal:OneSignal:'"$VERSION"'" />|' plugin.xml
121-
echo "✓ Updated plugin.xml with Android SDK ${VERSION}"
122-
123-
cd example/IonicCapOneSignal
124-
bunx cap sync android
125-
git add .
126-
else
127-
echo "✗ Android SDK version ${VERSION} not found"
120+
if [ -z "$RELEASE" ]; then
121+
echo "✗ Android SDK version ${VERSION} not found on GitHub"
128122
exit 1
129123
fi
130124
125+
# Update plugin.xml with new version
126+
# mac os sed syntax
127+
sed -i '' 's|<framework src="com\.onesignal:OneSignal:[^"]*" />|<framework src="com.onesignal:OneSignal:'"$VERSION"'" />|' plugin.xml
128+
echo "✓ Updated plugin.xml with Android SDK ${VERSION}"
129+
130+
cd example/IonicCapOneSignal
131+
bunx cap sync android
132+
133+
# Only commit if there are changes
134+
git add -A
135+
git diff --staged --quiet && exit 0
136+
git commit -m "Update Android SDK to ${VERSION}" && git push
137+
131138
- name: Update iOS SDK version
132139
if: inputs.ios_version != ''
133140
run: |
@@ -137,29 +144,30 @@ jobs:
137144
RELEASE=$(curl -s -H "Authorization: token ${{ github.token }}" \
138145
"https://api.github.com/repos/OneSignal/OneSignal-iOS-SDK/releases/tags/${VERSION}")
139146
140-
if sed -n '/\"id\"/p' <<< "$RELEASE" | grep -q .; then
141-
# Update plugin.xml with new version
142-
# mac os sed syntax
143-
sed -i '' "s|<pod name=\"OneSignalXCFramework\" spec=\"[^\"]*\" />|<pod name=\"OneSignalXCFramework\" spec=\"${VERSION}\" />|" plugin.xml
144-
echo "✓ Updated plugin.xml with iOS SDK ${VERSION}"
145-
146-
# Need to regenerate the Podfile.lock
147-
cd example/IonicCapOneSignal/ios/App
148-
rm -f Podfile.lock
149-
cd ../..
150-
bunx cap sync ios
151-
git add .
152-
153-
else
147+
if [ -z "$RELEASE" ]; then
154148
echo "✗ iOS SDK version ${VERSION} not found"
155149
exit 1
156150
fi
157151
152+
# Update plugin.xml with new version
153+
# mac os sed syntax
154+
sed -i '' "s|<pod name=\"OneSignalXCFramework\" spec=\"[^\"]*\" />|<pod name=\"OneSignalXCFramework\" spec=\"${VERSION}\" />|" plugin.xml
155+
echo "✓ Updated plugin.xml with iOS SDK ${VERSION}"
156+
157+
# Need to regenerate the Podfile.lock
158+
cd example/IonicCapOneSignal/ios/App
159+
rm -f Podfile.lock
160+
cd ../..
161+
bunx cap sync ios
162+
163+
# Only commit if there are changes
164+
git add -A
165+
git diff --staged --quiet && exit 0
166+
git commit -m "Update iOS SDK to ${VERSION}" && git push
167+
158168
- name: Update sdk version
159169
run: |
160170
NEW_VERSION="${{ inputs.cordova_version }}"
161-
git config user.name "github-actions[bot]"
162-
git config user.email "github-actions[bot]@users.noreply.github.com"
163171
164172
# Convert version format for OneSignal wrapper (e.g., 5.2.15 -> 050215)
165173
# For pre-releases, extract base version first (e.g., 5.2.15-alpha.1 -> 5.2.15)
@@ -178,10 +186,10 @@ jobs:
178186
# Update OneSignalPush.m wrapper version
179187
sed -i '' "s/OneSignalWrapper\.sdkVersion = @\"[^\"]*\"/OneSignalWrapper.sdkVersion = @\"$WRAPPER_VERSION\"/g" src/ios/OneSignalPush.m
180188
181-
git add package.json plugin.xml src/android/com/onesignal/cordova/OneSignalPush.java src/ios/OneSignalPush.m
182-
183-
git commit -m "Release $NEW_VERSION"
184-
git push
189+
# Only commit if there are changes
190+
git add -A
191+
git diff --staged --quiet && exit 0
192+
git commit -m "Release $NEW_VERSION" && git push
185193
186194
create-pr:
187195
needs: [prep, update_version]

0 commit comments

Comments
 (0)