Skip to content

Commit 01d0e20

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

4 files changed

Lines changed: 49 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: 46 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:
@@ -85,12 +87,16 @@ jobs:
8587
uses: actions/checkout@v4
8688
with:
8789
path: ./package-repo
90+
token: ${{secrets.GITHUB_TOKEN}}
8891
fetch-depth: 0
8992

93+
- name: Authenticate with GitHub
94+
run : |
95+
gh auth login --with-token <<< "${{secrets.GITHUB_TOKEN}}"
96+
9097
- name: Show branches/tags and checkout debian/upstream latest
98+
working-directory: ./package-repo
9199
run: |
92-
cd ./package-repo
93-
94100
git branch
95101
git tag
96102
git checkout ${{inputs.debian-branch}}
@@ -102,18 +108,16 @@ jobs:
102108
fi
103109
104110
- name: Make sure the upstream tag is not already part of the repo
111+
working-directory: ./package-repo
105112
run: |
106-
cd ./package-repo
107-
108113
if (git tag --list | grep "${{inputs.upstream-tag}}"); then
109114
echo "❌ The supplied upstream tag is wrong as it pertains to this repo already."
110115
exit 1
111116
fi
112117
113118
- name: Validate the upstream tag promotion state
119+
working-directory: ./package-repo
114120
run: |
115-
cd ./package-repo
116-
117121
# Check if the upstream/<normalized_version> tag does not already exists
118122
if ! git tag --list | grep "upstream/${{env.NORMALIZED_VERSION}}"; then
119123
echo "✅ The upstream tag '${{inputs.upstream-tag}}' has not been promoted yet. Continuing."
@@ -136,7 +140,6 @@ jobs:
136140
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"
137141
138142
# Check if there is a PR open for this already
139-
gh auth login --with-token <<< "${{secrets.DEB_PKG_BOT_CI_TOKEN}}"
140143
PRS=$(gh pr list --head "debian/pr/${{env.NORMALIZED_VERSION}}-1" --state open --json number --jq '.[].number')
141144
if [ -n "$PRS" ]; then
142145
echo "❌ An open PR already exists for this promotion attempt: $PRS"
@@ -161,23 +164,47 @@ jobs:
161164
fi
162165
163166
- name: Add Upstream Link As A Remote And Fetch Tags
167+
working-directory: ./package-repo
164168
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/*"
169+
if [ -n "${{secrets.UPSTREAM_REPO_READ_PAT}}" ]; then
170+
echo "ℹ️ Adding upstream remote with token authentication. This is because the upstream repository may be private and require authentication to fetch tags."
171+
REPO_URL=https://x-access-token:${{secrets.UPSTREAM_REPO_READ_PAT}}@github.com/${{inputs.upstream-repo}}.git
172+
else
173+
echo "ℹ️ Adding upstream remote without token authentication, repo is assumed to be public"
174+
REPO_URL=https://github.com/${{inputs.upstream-repo}}.git
175+
fi
176+
177+
git remote add upstream-source $REPO_URL
178+
179+
echo "ℹ️ Fetching tags from upstream repository using token authentication."
180+
181+
# Override the global extraheader set by actions/checkout (GITHUB_TOKEN) which would otherwise
182+
# take precedence over the credentials embedded in the URL and prevent access to external repos.
183+
# if ! git -c http.https://github.com/.extraheader="" fetch upstream-source "+refs/tags/*:refs/tags/*"; then
184+
if ! git fetch upstream-source "+refs/tags/*:refs/tags/*"; then
185+
echo "❌ Failed to fetch tags from '${{inputs.upstream-repo}}'."
186+
187+
if [ -n "${{secrets.UPSTREAM_REPO_READ_PAT}}" ]; then
188+
echo "❌ Ensure that the UPSTREAM_REPO_READ_PAT token has the permission on the repository."
189+
echo "❌ For more information about this token, see the README.md in qcom-build-utils repo."
190+
else
191+
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."
192+
fi
193+
194+
exit 1
195+
fi
168196
169197
- name: Ensure the tag exists in the upstream repo
198+
working-directory: ./package-repo
170199
run: |
171-
cd ./package-repo
172-
173200
if ! git rev-parse --verify "refs/tags/${{inputs.upstream-tag}}" >/dev/null 2>&1; then
174201
echo "❌ The specified upstream tag '${{inputs.upstream-tag}}' does not exist in the upstream repository."
175202
exit 1
176203
fi
177204
178205
- name: Pre-populate the upstream/latest branch if first promotion
206+
working-directory: ./package-repo
179207
run: |
180-
cd ./package-repo
181208
182209
# If the upstream/latest branch does not exist yet, create it and give it
183210
# the history of upstream directly, instead of creating an --allow-empty commit
@@ -191,9 +218,8 @@ jobs:
191218
fi
192219
193220
- name: Merge upstream tag into packaging branch
221+
working-directory: ./package-repo
194222
run: |
195-
cd ./package-repo
196-
197223
git config user.name "${{vars.DEB_PKG_BOT_CI_NAME}}"
198224
git config user.email "${{vars.DEB_PKG_BOT_CI_EMAIL}}"
199225
@@ -204,9 +230,8 @@ jobs:
204230
../qcom-build-utils/scripts/merge_debian_packaging_upstream ${{inputs.upstream-tag}}
205231
206232
- name: Promote Changelog
233+
working-directory: ./package-repo
207234
run: |
208-
cd ./package-repo
209-
210235
export DEBFULLNAME="${{vars.DEB_PKG_BOT_CI_NAME}}"
211236
export DEBEMAIL="${{vars.DEB_PKG_BOT_CI_EMAIL}}"
212237
@@ -219,9 +244,8 @@ jobs:
219244
git commit -a -s -m "Update changelog version to ${{env.NORMALIZED_VERSION}}-1 and UNRELEASED suite"
220245
221246
- name: Push Upstream/latest and debian PR Branch
247+
working-directory: ./package-repo
222248
run: |
223-
cd ./package-repo
224-
225249
if [ "${{env.UPSTREAM_TAG_ALREADY_EXISTS}}" = "false" ]; then
226250
# This is the happy path where no previous promotion attempt was detected
227251
@@ -237,12 +261,8 @@ jobs:
237261
git push origin debian/pr/${{env.NORMALIZED_VERSION}}-1
238262
239263
- name: Open Promotion PR
264+
working-directory: ./package-repo
240265
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-
246266
../qcom-build-utils/scripts/create_promotion_pr.py \
247267
--base-branch "${{inputs.debian-branch}}" \
248268
--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)