Skip to content

Commit a4eb911

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

4 files changed

Lines changed: 47 additions & 29 deletions

.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: 44 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,46 @@ 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+
# Override the global extraheader set by actions/checkout (GITHUB_TOKEN) which would otherwise
181+
# take precedence over the credentials embedded in the URL and prevent access to external repos.
182+
if ! git -c http.https://github.com/.extraheader="" fetch upstream-source "+refs/tags/*:refs/tags/*"; then
183+
echo "❌ Failed to fetch tags from '${{inputs.upstream-repo}}'."
184+
185+
if [ -n "${{secrets.UPSTREAM_REPO_READ_PAT}}" ]; then
186+
echo "❌ Ensure that the UPSTREAM_REPO_READ_PAT token has the permission on the repository."
187+
echo "❌ For more information about this token, see the README.md in qcom-build-utils repo."
188+
else
189+
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."
190+
fi
191+
192+
exit 1
193+
fi
168194
169195
- name: Ensure the tag exists in the upstream repo
196+
working-directory: ./package-repo
170197
run: |
171-
cd ./package-repo
172-
173198
if ! git rev-parse --verify "refs/tags/${{inputs.upstream-tag}}" >/dev/null 2>&1; then
174199
echo "❌ The specified upstream tag '${{inputs.upstream-tag}}' does not exist in the upstream repository."
175200
exit 1
176201
fi
177202
178203
- name: Pre-populate the upstream/latest branch if first promotion
204+
working-directory: ./package-repo
179205
run: |
180-
cd ./package-repo
181206
182207
# If the upstream/latest branch does not exist yet, create it and give it
183208
# the history of upstream directly, instead of creating an --allow-empty commit
@@ -191,9 +216,8 @@ jobs:
191216
fi
192217
193218
- name: Merge upstream tag into packaging branch
219+
working-directory: ./package-repo
194220
run: |
195-
cd ./package-repo
196-
197221
git config user.name "${{vars.DEB_PKG_BOT_CI_NAME}}"
198222
git config user.email "${{vars.DEB_PKG_BOT_CI_EMAIL}}"
199223
@@ -204,9 +228,8 @@ jobs:
204228
../qcom-build-utils/scripts/merge_debian_packaging_upstream ${{inputs.upstream-tag}}
205229
206230
- name: Promote Changelog
231+
working-directory: ./package-repo
207232
run: |
208-
cd ./package-repo
209-
210233
export DEBFULLNAME="${{vars.DEB_PKG_BOT_CI_NAME}}"
211234
export DEBEMAIL="${{vars.DEB_PKG_BOT_CI_EMAIL}}"
212235
@@ -219,9 +242,8 @@ jobs:
219242
git commit -a -s -m "Update changelog version to ${{env.NORMALIZED_VERSION}}-1 and UNRELEASED suite"
220243
221244
- name: Push Upstream/latest and debian PR Branch
245+
working-directory: ./package-repo
222246
run: |
223-
cd ./package-repo
224-
225247
if [ "${{env.UPSTREAM_TAG_ALREADY_EXISTS}}" = "false" ]; then
226248
# This is the happy path where no previous promotion attempt was detected
227249
@@ -237,12 +259,8 @@ jobs:
237259
git push origin debian/pr/${{env.NORMALIZED_VERSION}}-1
238260
239261
- name: Open Promotion PR
262+
working-directory: ./package-repo
240263
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-
246264
../qcom-build-utils/scripts/create_promotion_pr.py \
247265
--base-branch "${{inputs.debian-branch}}" \
248266
--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)