Skip to content

Commit d0c5526

Browse files
test
Signed-off-by: Simon Beaudoin <sbeaudoi@qti.qualcomm.com>
1 parent 01d0e20 commit d0c5526

1 file changed

Lines changed: 28 additions & 12 deletions

File tree

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

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@ on:
3232
required: true
3333

3434
secrets:
35-
UPSTREAM_REPO_READ_PAT:
35+
PAT:
3636
required: false
3737

3838
permissions:
3939
contents: write
4040
packages: read
41+
pull-requests: write
4142

4243
env:
4344
NORMALIZED_VERSION: ""
@@ -87,12 +88,11 @@ jobs:
8788
uses: actions/checkout@v4
8889
with:
8990
path: ./package-repo
90-
token: ${{secrets.GITHUB_TOKEN}}
9191
fetch-depth: 0
9292

9393
- name: Authenticate with GitHub
9494
run : |
95-
gh auth login --with-token <<< "${{secrets.GITHUB_TOKEN}}"
95+
gh auth login --with-token <<< "${{secrets.PAT}}"
9696
9797
- name: Show branches/tags and checkout debian/upstream latest
9898
working-directory: ./package-repo
@@ -166,9 +166,9 @@ jobs:
166166
- name: Add Upstream Link As A Remote And Fetch Tags
167167
working-directory: ./package-repo
168168
run: |
169-
if [ -n "${{secrets.UPSTREAM_REPO_READ_PAT}}" ]; then
169+
if [ -n "${{secrets.PAT}}" ]; then
170170
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
171+
REPO_URL=https://x-access-token:${{secrets.PAT}}@github.com/${{inputs.upstream-repo}}.git
172172
else
173173
echo "ℹ️ Adding upstream remote without token authentication, repo is assumed to be public"
174174
REPO_URL=https://github.com/${{inputs.upstream-repo}}.git
@@ -180,15 +180,14 @@ jobs:
180180
181181
# Override the global extraheader set by actions/checkout (GITHUB_TOKEN) which would otherwise
182182
# 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
183+
if ! git -c http.https://github.com/.extraheader="" fetch upstream-source "+refs/tags/*:refs/tags/*"; then
185184
echo "❌ Failed to fetch tags from '${{inputs.upstream-repo}}'."
186185
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."
186+
if [ -n "${{secrets.PAT}}" ]; then
187+
echo "❌ Ensure that the PAT token has the permission on the repository."
189188
echo "❌ For more information about this token, see the README.md in qcom-build-utils repo."
190189
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."
190+
echo "❌ Make sure the upstream repository is public or if it is private that the PAT token is set and has the necessary permissions."
192191
fi
193192
194193
exit 1
@@ -202,7 +201,7 @@ jobs:
202201
exit 1
203202
fi
204203
205-
- name: Pre-populate the upstream/latest branch if first promotion
204+
- name: Merge upstream tag into upstream/latest
206205
working-directory: ./package-repo
207206
run: |
208207
@@ -214,7 +213,24 @@ jobs:
214213
else
215214
# The branch exists, check it out and promote it to the upstream tag
216215
git checkout upstream/latest
217-
git merge --ff-only ${{inputs.upstream-tag}}
216+
git merge ${{inputs.upstream-tag}}
217+
fi
218+
219+
- name: Strip .github/workflows from upstream/latest
220+
working-directory: ./package-repo
221+
run: |
222+
# Since Github does not allow pushing workflows using the GITHUB_TOKEN, remove .github/workflows if present.
223+
224+
git config user.name "${{vars.DEB_PKG_BOT_CI_NAME}}"
225+
git config user.email "${{vars.DEB_PKG_BOT_CI_EMAIL}}"
226+
227+
git checkout upstream/latest
228+
229+
# Remove .github/workflows/ if present to avoid GITHUB_TOKEN push restrictions.
230+
# The upstream source repo workflows are not relevant to the packaging repo.
231+
if [ -d .github/workflows ]; then
232+
git rm -rf .github/workflows
233+
git commit -s -m "Remove .github/workflows from upstream source"
218234
fi
219235
220236
- name: Merge upstream tag into packaging branch

0 commit comments

Comments
 (0)