Skip to content

Commit 2264c8b

Browse files
token: switch over to GITHUB_TOKEN
Signed-off-by: Simon Beaudoin <sbeaudoi@qti.qualcomm.com>
1 parent 00ff040 commit 2264c8b

File tree

4 files changed

+45
-29
lines changed

4 files changed

+45
-29
lines changed

.github/workflows/qcom-promote-prebuilt-reusable-workflow.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ jobs:
231231
run: |
232232
cd ./package-repo
233233
234-
gh auth login --with-token <<< "${{secrets.DEB_PKG_BOT_CI_TOKEN}}"
234+
gh auth login --with-token <<< "${{secrets.GITHUB_TOKEN}}"
235235
236236
PR_TITLE="Promotion to ${{env.NEW_DEBIAN_VERSION}} (Artifactory tag: ${{inputs.new-tag}})"
237237

.github/workflows/qcom-promote-upstream-reusable-workflow.yml

Lines changed: 42 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,16 @@ on:
3131
type: string
3232
required: true
3333

34+
secrets:
35+
UPSTREAM_REPO_READ_PAT:
36+
required: false
37+
3438
permissions:
3539
contents: write
3640
packages: read
3741

3842
env:
3943
NORMALIZED_VERSION: ""
40-
DISTRIBUTION: noble
41-
4244
UPSTREAM_TAG_ALREADY_EXISTS: false
4345

4446
jobs:
@@ -87,10 +89,13 @@ jobs:
8789
path: ./package-repo
8890
fetch-depth: 0
8991

92+
- name: Authenticate with GitHub
93+
run : |
94+
gh auth login --with-token <<< "${{secrets.GITHUB_TOKEN}}"
95+
9096
- name: Show branches/tags and checkout debian/upstream latest
97+
working-directory: ./package-repo
9198
run: |
92-
cd ./package-repo
93-
9499
git branch
95100
git tag
96101
git checkout ${{inputs.debian-branch}}
@@ -102,18 +107,16 @@ jobs:
102107
fi
103108
104109
- name: Make sure the upstream tag is not already part of the repo
110+
working-directory: ./package-repo
105111
run: |
106-
cd ./package-repo
107-
108112
if (git tag --list | grep "${{inputs.upstream-tag}}"); then
109113
echo "❌ The supplied upstream tag is wrong as it pertains to this repo already."
110114
exit 1
111115
fi
112116
113117
- name: Validate the upstream tag promotion state
118+
working-directory: ./package-repo
114119
run: |
115-
cd ./package-repo
116-
117120
# Check if the upstream/<normalized_version> tag does not already exists
118121
if ! git tag --list | grep "upstream/${{env.NORMALIZED_VERSION}}"; then
119122
echo "✅ The upstream tag '${{inputs.upstream-tag}}' has not been promoted yet. Continuing."
@@ -136,7 +139,6 @@ jobs:
136139
echo "ℹ️ This is likely a second attempt to promote the same upstream tag, where the first attempt already added the upstream tag in the upstram branch"
137140
138141
# Check if there is a PR open for this already
139-
gh auth login --with-token <<< "${{secrets.DEB_PKG_BOT_CI_TOKEN}}"
140142
PRS=$(gh pr list --head "debian/pr/${{env.NORMALIZED_VERSION}}-1" --state open --json number --jq '.[].number')
141143
if [ -n "$PRS" ]; then
142144
echo "❌ An open PR already exists for this promotion attempt: $PRS"
@@ -161,23 +163,44 @@ jobs:
161163
fi
162164
163165
- name: Add Upstream Link As A Remote And Fetch Tags
166+
working-directory: ./package-repo
164167
run: |
165-
cd ./package-repo
166-
git remote add upstream-source https://x-access-token:${{secrets.DEB_PKG_BOT_CI_TOKEN}}@github.com/${{inputs.upstream-repo}}.git
167-
git fetch upstream-source "+refs/tags/*:refs/tags/*"
168+
if [ -n "${{secrets.UPSTREAM_REPO_READ_PAT}}" ]; then
169+
echo "ℹ️ Adding upstream remote with token authentication. This is because the upstream repository may be private and require authentication to fetch tags."
170+
REPO_URL=https://x-access-token:${{secrets.UPSTREAM_REPO_READ_PAT}}@github.com/${{inputs.upstream-repo}}.git
171+
else
172+
echo "ℹ️ Adding upstream remote without token authentication, repo is assumed to be public"
173+
REPO_URL=https://github.com/${{inputs.upstream-repo}}.git
174+
fi
175+
176+
git remote add upstream-source $REPO_URL
177+
178+
echo "ℹ️ Fetching tags from upstream repository using token authentication."
179+
180+
if ! git fetch upstream-source "+refs/tags/*:refs/tags/*"; then
181+
echo "❌ Failed to fetch tags from '${{inputs.upstream-repo}}'."
182+
183+
if [ -n "${{secrets.UPSTREAM_REPO_READ_PAT}}" ]; then
184+
echo "❌ Ensure that the UPSTREAM_REPO_READ_PAT token has the permission on the repository."
185+
echo "❌ For more information about this token, see the README.md in qcom-build-utils repo."
186+
else
187+
echo "❌ Make sure the upstream repository is public or if it is private that the UPSTREAM_REPO_READ_PAT token is set and has the necessary permissions."
188+
fi
189+
`
190+
exit 1
191+
fi
168192
169193
- name: Ensure the tag exists in the upstream repo
194+
working-directory: ./package-repo
170195
run: |
171-
cd ./package-repo
172-
173196
if ! git rev-parse --verify "refs/tags/${{inputs.upstream-tag}}" >/dev/null 2>&1; then
174197
echo "❌ The specified upstream tag '${{inputs.upstream-tag}}' does not exist in the upstream repository."
175198
exit 1
176199
fi
177200
178201
- name: Pre-populate the upstream/latest branch if first promotion
202+
working-directory: ./package-repo
179203
run: |
180-
cd ./package-repo
181204
182205
# If the upstream/latest branch does not exist yet, create it and give it
183206
# the history of upstream directly, instead of creating an --allow-empty commit
@@ -191,9 +214,8 @@ jobs:
191214
fi
192215
193216
- name: Merge upstream tag into packaging branch
217+
working-directory: ./package-repo
194218
run: |
195-
cd ./package-repo
196-
197219
git config user.name "${{vars.DEB_PKG_BOT_CI_NAME}}"
198220
git config user.email "${{vars.DEB_PKG_BOT_CI_EMAIL}}"
199221
@@ -204,9 +226,8 @@ jobs:
204226
../qcom-build-utils/scripts/merge_debian_packaging_upstream ${{inputs.upstream-tag}}
205227
206228
- name: Promote Changelog
229+
working-directory: ./package-repo
207230
run: |
208-
cd ./package-repo
209-
210231
export DEBFULLNAME="${{vars.DEB_PKG_BOT_CI_NAME}}"
211232
export DEBEMAIL="${{vars.DEB_PKG_BOT_CI_EMAIL}}"
212233
@@ -219,9 +240,8 @@ jobs:
219240
git commit -a -s -m "Update changelog version to ${{env.NORMALIZED_VERSION}}-1 and UNRELEASED suite"
220241
221242
- name: Push Upstream/latest and debian PR Branch
243+
working-directory: ./package-repo
222244
run: |
223-
cd ./package-repo
224-
225245
if [ "${{env.UPSTREAM_TAG_ALREADY_EXISTS}}" = "false" ]; then
226246
# This is the happy path where no previous promotion attempt was detected
227247
@@ -237,12 +257,8 @@ jobs:
237257
git push origin debian/pr/${{env.NORMALIZED_VERSION}}-1
238258
239259
- name: Open Promotion PR
260+
working-directory: ./package-repo
240261
run: |
241-
cd ./package-repo
242-
243-
# TODO remove this redundant login
244-
gh auth login --with-token <<< "${{secrets.DEB_PKG_BOT_CI_TOKEN}}"
245-
246262
../qcom-build-utils/scripts/create_promotion_pr.py \
247263
--base-branch "${{inputs.debian-branch}}" \
248264
--upstream-tag "${{inputs.upstream-tag}}" \

.github/workflows/qcom-release-reusable-workflow.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ jobs:
323323
- name: Notify qcom-distro-images of new release via repository dispatch
324324
uses: peter-evans/repository-dispatch@v3
325325
with:
326-
token: ${{secrets.DEB_PKG_BOT_CI_TOKEN}}
326+
token: ${{secrets.GITHUB_TOKEN}}
327327
repository: qualcomm-linux/qcom-distro-images
328328
event-type: pkg-repo-release
329329
client-payload: >-

.github/workflows/qcom-upstream-pr-pkg-build-reusable-workflow.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
options: --privileged
6666
credentials:
6767
username: ${{ github.actor }}
68-
password: ${{ secrets.GITHUB_TOKEN }}
68+
password: ${{ ITHUB_TOKEN }}
6969

7070
steps:
7171

0 commit comments

Comments
 (0)