Skip to content

Commit 6461025

Browse files
committed
optimize token usage
1 parent 4bb2b97 commit 6461025

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

.github/actions/setup-environment/action.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
name: 'Setup Environment'
22
description: 'Common setup steps for Unity release workflows (Git config and environment prep)'
33

4-
inputs:
5-
gh_token:
6-
description: 'GitHub token for gh CLI authentication'
7-
required: true
8-
94
runs:
105
using: 'composite'
116
steps:
@@ -17,7 +12,7 @@ runs:
1712
1813
- name: Prepare Environment
1914
env:
20-
GH_TOKEN: ${{ inputs.gh_token }}
15+
GH_TOKEN: ${{ github.token }}
2116
shell: bash
2217
run: |
2318
sudo apt-get update

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

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ jobs:
6060

6161
- name: Setup Environment
6262
uses: ./.github/actions/setup-environment
63-
with:
64-
gh_token: ${{ secrets.GITHUB_TOKEN }}
6563

6664
- name: Get current native SDK versions
6765
id: current_versions
@@ -140,7 +138,7 @@ jobs:
140138
ios_to: ${{ inputs.ios_version }}
141139

142140
draft-release:
143-
needs: [prep, update-version]
141+
needs: [prep, update-version, create-pr]
144142
runs-on: ubuntu-latest
145143
steps:
146144
- name: Checkout
@@ -150,8 +148,6 @@ jobs:
150148

151149
- name: Setup Environment
152150
uses: ./.github/actions/setup-environment
153-
with:
154-
gh_token: ${{ secrets.GITHUB_TOKEN }}
155151

156152
- name: Update Unity SDK version
157153
run: |
@@ -240,10 +236,27 @@ jobs:
240236
env:
241237
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
242238
run: |
243-
release_notes=$(gh pr view "${{ github.event.pull_request.number }}" --json body -q '.body')
239+
# Find the PR with the release branch as head
240+
RELEASE_BRANCH="${{ needs.prep.outputs.release_branch }}"
241+
echo "Looking for PR with head branch: $RELEASE_BRANCH"
242+
243+
# Get PR number from the branch
244+
PR_NUMBER=$(gh pr list --head "$RELEASE_BRANCH" --json number -q '.[0].number' || echo "")
245+
246+
if [ -z "$PR_NUMBER" ]; then
247+
echo "⚠️ No PR found for branch $RELEASE_BRANCH"
248+
echo "RELEASE_NOTES=" >> $GITHUB_ENV
249+
exit 0
250+
fi
251+
252+
echo "Found PR #$PR_NUMBER"
253+
release_notes=$(gh pr view "$PR_NUMBER" --json body -q '.body')
254+
255+
echo "Raw RELEASE_NOTES contents:"
256+
echo "$release_notes"
244257
245258
cleaned_notes=$(echo "$release_notes" \
246-
| awk '/^Update/{found=1} found' \
259+
| awk '/^- Update/{found=1} found' \
247260
| sed '/^- - -$/d' \
248261
| sed '/^[[:space:]]*$/d')
249262

0 commit comments

Comments
 (0)