Skip to content

Commit 1f3a4ba

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

File tree

4 files changed

+48
-29
lines changed

4 files changed

+48
-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: 45 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,17 @@ on:
3131
type: string
3232
required: true
3333

34+
secrets:
35+
UPSTREAM_REPO_READ_PAT:
36+
required: false
37+
3438
permissions:
3539
contents: write
40+
workflows: write
3641
packages: read
3742

3843
env:
3944
NORMALIZED_VERSION: ""
40-
DISTRIBUTION: noble
41-
4245
UPSTREAM_TAG_ALREADY_EXISTS: false
4346

4447
jobs:
@@ -87,10 +90,13 @@ jobs:
8790
path: ./package-repo
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,46 @@ 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+
echo "❌ Failed to fetch tags from '${{inputs.upstream-repo}}'."
185+
186+
if [ -n "${{secrets.UPSTREAM_REPO_READ_PAT}}" ]; then
187+
echo "❌ Ensure that the UPSTREAM_REPO_READ_PAT token has the permission on the repository."
188+
echo "❌ For more information about this token, see the README.md in qcom-build-utils repo."
189+
else
190+
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."
191+
fi
192+
193+
exit 1
194+
fi
168195
169196
- name: Ensure the tag exists in the upstream repo
197+
working-directory: ./package-repo
170198
run: |
171-
cd ./package-repo
172-
173199
if ! git rev-parse --verify "refs/tags/${{inputs.upstream-tag}}" >/dev/null 2>&1; then
174200
echo "❌ The specified upstream tag '${{inputs.upstream-tag}}' does not exist in the upstream repository."
175201
exit 1
176202
fi
177203
178204
- name: Pre-populate the upstream/latest branch if first promotion
205+
working-directory: ./package-repo
179206
run: |
180-
cd ./package-repo
181207
182208
# If the upstream/latest branch does not exist yet, create it and give it
183209
# the history of upstream directly, instead of creating an --allow-empty commit
@@ -191,9 +217,8 @@ jobs:
191217
fi
192218
193219
- name: Merge upstream tag into packaging branch
220+
working-directory: ./package-repo
194221
run: |
195-
cd ./package-repo
196-
197222
git config user.name "${{vars.DEB_PKG_BOT_CI_NAME}}"
198223
git config user.email "${{vars.DEB_PKG_BOT_CI_EMAIL}}"
199224
@@ -204,9 +229,8 @@ jobs:
204229
../qcom-build-utils/scripts/merge_debian_packaging_upstream ${{inputs.upstream-tag}}
205230
206231
- name: Promote Changelog
232+
working-directory: ./package-repo
207233
run: |
208-
cd ./package-repo
209-
210234
export DEBFULLNAME="${{vars.DEB_PKG_BOT_CI_NAME}}"
211235
export DEBEMAIL="${{vars.DEB_PKG_BOT_CI_EMAIL}}"
212236
@@ -219,9 +243,8 @@ jobs:
219243
git commit -a -s -m "Update changelog version to ${{env.NORMALIZED_VERSION}}-1 and UNRELEASED suite"
220244
221245
- name: Push Upstream/latest and debian PR Branch
246+
working-directory: ./package-repo
222247
run: |
223-
cd ./package-repo
224-
225248
if [ "${{env.UPSTREAM_TAG_ALREADY_EXISTS}}" = "false" ]; then
226249
# This is the happy path where no previous promotion attempt was detected
227250
@@ -237,12 +260,8 @@ jobs:
237260
git push origin debian/pr/${{env.NORMALIZED_VERSION}}-1
238261
239262
- name: Open Promotion PR
263+
working-directory: ./package-repo
240264
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-
246265
../qcom-build-utils/scripts/create_promotion_pr.py \
247266
--base-branch "${{inputs.debian-branch}}" \
248267
--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)