Skip to content

Commit e0b418a

Browse files
authored
ci: add gh push token secret for release automation (#824)
1 parent 3fc3f90 commit e0b418a

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

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

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
1-
name: Create Unity Release PR
1+
name: Create Release PR
22

33
on:
44
# For making a release pr from android / ios sdk actions
55
workflow_call:
6+
secrets:
7+
GH_PUSH_TOKEN:
8+
required: false
9+
description: "GitHub token for pushing changes (from a different caller repo)"
610
inputs:
711
unity_version:
8-
description: 'New Unity Version (e.g., 5.2.15 or 5.2.15-beta.1)'
12+
description: "New Unity Version (e.g., 5.2.15 or 5.2.15-beta.1)"
913
required: true
1014
type: string
1115
android_version:
12-
description: 'New Android SDK Version (e.g., 2.3.0). Leave blank to skip.'
16+
description: "New Android SDK Version (e.g., 2.3.0). Leave blank to skip."
1317
required: false
1418
type: string
1519
ios_version:
16-
description: 'New iOS SDK Version (e.g., 1.5.0). Leave blank to skip.'
20+
description: "New iOS SDK Version (e.g., 1.5.0). Leave blank to skip."
1721
required: false
1822
type: string
1923
target_branch:
20-
description: 'Target branch to create the release PR on. Defaults to main.'
24+
description: "Target branch to create the release PR on. Defaults to main."
2125
required: false
2226
type: string
2327
default: main
@@ -26,19 +30,19 @@ on:
2630
workflow_dispatch:
2731
inputs:
2832
unity_version:
29-
description: 'New Unity Version (e.g., 5.2.15 or 5.2.15-beta.1)'
33+
description: "New Unity Version (e.g., 5.2.15 or 5.2.15-beta.1)"
3034
required: true
3135
type: string
3236
android_version:
33-
description: 'New Android SDK Version (e.g., 2.3.0). Leave blank to skip.'
37+
description: "New Android SDK Version (e.g., 2.3.0). Leave blank to skip."
3438
required: false
3539
type: string
3640
ios_version:
37-
description: 'New iOS SDK Version (e.g., 1.5.0). Leave blank to skip.'
41+
description: "New iOS SDK Version (e.g., 1.5.0). Leave blank to skip."
3842
required: false
3943
type: string
4044
target_branch:
41-
description: 'Target branch to create the release PR on. Defaults to main.'
45+
description: "Target branch to create the release PR on. Defaults to main."
4246
required: false
4347
type: string
4448
default: main
@@ -50,7 +54,12 @@ permissions:
5054
jobs:
5155
prep:
5256
uses: OneSignal/sdk-actions/.github/workflows/prep-release.yml@main
57+
secrets:
58+
# Need this cross-repo token (sdk-actions & this repo) to perform changes
59+
GH_PUSH_TOKEN: ${{ secrets.GH_PUSH_TOKEN }}
5360
with:
61+
# Need target_repo otherwise caller would set github.repository to the caller itself (e.g. sdk-actions)
62+
target_repo: OneSignal/OneSignal-Unity-SDK
5463
version: ${{ inputs.unity_version }}
5564

5665
# Unity specific steps
@@ -66,7 +75,9 @@ jobs:
6675
- name: Checkout
6776
uses: actions/checkout@v5
6877
with:
78+
repository: OneSignal/OneSignal-Unity-SDK
6979
ref: ${{ needs.prep.outputs.release_branch }}
80+
token: ${{ secrets.GH_PUSH_TOKEN || github.token }}
7081

7182
- name: Get current native SDK versions
7283
id: current_versions
@@ -112,7 +123,7 @@ jobs:
112123
sed -i "s/\"com.onesignal.unity.core\": \"[0-9.]\+\"/\"com.onesignal.unity.core\": \"${{ inputs.unity_version }}\"/g" OneSignalExample/Packages/packages-lock.json
113124
sed -i "s/bundleVersion: .*/bundleVersion: ${{ inputs.unity_version }}/" OneSignalExample/ProjectSettings/ProjectSettings.asset
114125
sed -i "s/setSdkVersion:@\"[0-9]*\"/setSdkVersion:@\"${PADDED_VERSION}\"/" com.onesignal.unity.ios/Runtime/Plugins/iOS/UIApplication+OneSignalUnity.mm
115-
126+
116127
git config user.name "github-actions[bot]"
117128
git config user.email "github-actions[bot]@users.noreply.github.com"
118129
git add . && git commit -m "Release ${{ inputs.unity_version }}" && git push
@@ -121,6 +132,8 @@ jobs:
121132
needs: [prep, update-version]
122133
uses: OneSignal/sdk-actions/.github/workflows/create-release.yml@main
123134
with:
135+
# Need target_repo otherwise caller would set github.repository to the caller itself (e.g. sdk-actions)
136+
target_repo: OneSignal/OneSignal-Unity-SDK
124137
release_branch: ${{ needs.prep.outputs.release_branch }}
125138
target_branch: ${{ inputs.target_branch }}
126139
android_from: ${{ needs.update-version.outputs.android_from }}
@@ -155,4 +168,4 @@ jobs:
155168
OneSignalExample/Assets/OneSignal/CHANGELOG.md > /tmp/changelog.tmp && mv /tmp/changelog.tmp OneSignalExample/Assets/OneSignal/CHANGELOG.md
156169
git config user.name "github-actions[bot]"
157170
git config user.email "github-actions[bot]@users.noreply.github.com"
158-
git add . && git commit -m "Update CHANGELOG.md for ${{ inputs.unity_version }}" && git push
171+
git add . && git commit -m "Update CHANGELOG.md for ${{ inputs.unity_version }}" && git push

0 commit comments

Comments
 (0)