Skip to content

Commit 4906fb0

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

4 files changed

Lines changed: 39 additions & 27 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: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ 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
@@ -87,10 +91,13 @@ jobs:
8791
path: ./package-repo
8892
fetch-depth: 0
8993

94+
- name: Authenticate with GitHub
95+
run : |
96+
gh auth login --with-token <<< "${{secrets.GITHUB_TOKEN}}"
97+
9098
- name: Show branches/tags and checkout debian/upstream latest
99+
working-directory: ./package-repo
91100
run: |
92-
cd ./package-repo
93-
94101
git branch
95102
git tag
96103
git checkout ${{inputs.debian-branch}}
@@ -102,18 +109,16 @@ jobs:
102109
fi
103110
104111
- name: Make sure the upstream tag is not already part of the repo
112+
working-directory: ./package-repo
105113
run: |
106-
cd ./package-repo
107-
108114
if (git tag --list | grep "${{inputs.upstream-tag}}"); then
109115
echo "❌ The supplied upstream tag is wrong as it pertains to this repo already."
110116
exit 1
111117
fi
112118
113119
- name: Validate the upstream tag promotion state
120+
working-directory: ./package-repo
114121
run: |
115-
cd ./package-repo
116-
117122
# Check if the upstream/<normalized_version> tag does not already exists
118123
if ! git tag --list | grep "upstream/${{env.NORMALIZED_VERSION}}"; then
119124
echo "✅ The upstream tag '${{inputs.upstream-tag}}' has not been promoted yet. Continuing."
@@ -136,7 +141,6 @@ jobs:
136141
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"
137142
138143
# Check if there is a PR open for this already
139-
gh auth login --with-token <<< "${{secrets.DEB_PKG_BOT_CI_TOKEN}}"
140144
PRS=$(gh pr list --head "debian/pr/${{env.NORMALIZED_VERSION}}-1" --state open --json number --jq '.[].number')
141145
if [ -n "$PRS" ]; then
142146
echo "❌ An open PR already exists for this promotion attempt: $PRS"
@@ -161,23 +165,38 @@ jobs:
161165
fi
162166
163167
- name: Add Upstream Link As A Remote And Fetch Tags
168+
working-directory: ./package-repo
164169
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/*"
170+
if [ -n "${{secrets.UPSTREAM_REPO_READ_PAT}}" ]; then
171+
echo "ℹ️ Adding upstream remote with token authentication. This is because the upstream repository may be private and require authentication to fetch tags."
172+
git remote add upstream-source https://x-access-token:${{secrets.UPSTREAM_REPO_READ_PAT}}@github.com/${{inputs.upstream-repo}}.git
173+
if ! git fetch upstream-source "+refs/tags/*:refs/tags/*"; then
174+
echo "❌ Failed to fetch tags from '${{inputs.upstream-repo}}' with the supplied token."
175+
echo "❌ Ensure that the UPSTREAM_REPO_READ_PAT token has the necessary read permission on the repository."
176+
echo "❌ For more information about this token, see the README.md in qcom-build-utils repo."
177+
exit 1
178+
fi
179+
else
180+
echo "ℹ️ Adding upstream remote without token authentication, repo is assumed to be public"
181+
git remote add upstream-source https://github.com/${{inputs.upstream-repo}}.git
182+
if ! git fetch upstream-source "+refs/tags/*:refs/tags/*"; then
183+
echo "❌ Failed to fetch from '${{inputs.upstream-repo}}'."
184+
echo "❌ The repository may be private. If so, supply a UPSTREAM_REPO_READ_PAT secret with read access in the secrets of this repo."
185+
exit 1
186+
fi
187+
fi
168188
169189
- name: Ensure the tag exists in the upstream repo
190+
working-directory: ./package-repo
170191
run: |
171-
cd ./package-repo
172-
173192
if ! git rev-parse --verify "refs/tags/${{inputs.upstream-tag}}" >/dev/null 2>&1; then
174193
echo "❌ The specified upstream tag '${{inputs.upstream-tag}}' does not exist in the upstream repository."
175194
exit 1
176195
fi
177196
178197
- name: Pre-populate the upstream/latest branch if first promotion
198+
working-directory: ./package-repo
179199
run: |
180-
cd ./package-repo
181200
182201
# If the upstream/latest branch does not exist yet, create it and give it
183202
# the history of upstream directly, instead of creating an --allow-empty commit
@@ -191,9 +210,8 @@ jobs:
191210
fi
192211
193212
- name: Merge upstream tag into packaging branch
213+
working-directory: ./package-repo
194214
run: |
195-
cd ./package-repo
196-
197215
git config user.name "${{vars.DEB_PKG_BOT_CI_NAME}}"
198216
git config user.email "${{vars.DEB_PKG_BOT_CI_EMAIL}}"
199217
@@ -204,9 +222,8 @@ jobs:
204222
../qcom-build-utils/scripts/merge_debian_packaging_upstream ${{inputs.upstream-tag}}
205223
206224
- name: Promote Changelog
225+
working-directory: ./package-repo
207226
run: |
208-
cd ./package-repo
209-
210227
export DEBFULLNAME="${{vars.DEB_PKG_BOT_CI_NAME}}"
211228
export DEBEMAIL="${{vars.DEB_PKG_BOT_CI_EMAIL}}"
212229
@@ -219,9 +236,8 @@ jobs:
219236
git commit -a -s -m "Update changelog version to ${{env.NORMALIZED_VERSION}}-1 and UNRELEASED suite"
220237
221238
- name: Push Upstream/latest and debian PR Branch
239+
working-directory: ./package-repo
222240
run: |
223-
cd ./package-repo
224-
225241
if [ "${{env.UPSTREAM_TAG_ALREADY_EXISTS}}" = "false" ]; then
226242
# This is the happy path where no previous promotion attempt was detected
227243
@@ -237,12 +253,8 @@ jobs:
237253
git push origin debian/pr/${{env.NORMALIZED_VERSION}}-1
238254
239255
- name: Open Promotion PR
256+
working-directory: ./package-repo
240257
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-
246258
../qcom-build-utils/scripts/create_promotion_pr.py \
247259
--base-branch "${{inputs.debian-branch}}" \
248260
--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)