Skip to content

Commit 09247b2

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

1 file changed

Lines changed: 28 additions & 11 deletions

File tree

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

Lines changed: 28 additions & 11 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: ""
@@ -86,13 +87,13 @@ jobs:
8687
- name: Checkout Repository
8788
uses: actions/checkout@v4
8889
with:
90+
token: ${{secrets.PAT}}
8991
path: ./package-repo
90-
token: ${{secrets.GITHUB_TOKEN}}
9192
fetch-depth: 0
9293

9394
- name: Authenticate with GitHub
9495
run : |
95-
gh auth login --with-token <<< "${{secrets.GITHUB_TOKEN}}"
96+
gh auth login --with-token <<< "${{secrets.PAT}}"
9697
9798
- name: Show branches/tags and checkout debian/upstream latest
9899
working-directory: ./package-repo
@@ -166,9 +167,9 @@ jobs:
166167
- name: Add Upstream Link As A Remote And Fetch Tags
167168
working-directory: ./package-repo
168169
run: |
169-
if [ -n "${{secrets.UPSTREAM_REPO_READ_PAT}}" ]; then
170+
if [ -n "${{secrets.PAT}}" ]; then
170171
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+
REPO_URL=https://x-access-token:${{secrets.PAT}}@github.com/${{inputs.upstream-repo}}.git
172173
else
173174
echo "ℹ️ Adding upstream remote without token authentication, repo is assumed to be public"
174175
REPO_URL=https://github.com/${{inputs.upstream-repo}}.git
@@ -180,15 +181,14 @@ jobs:
180181
181182
# Override the global extraheader set by actions/checkout (GITHUB_TOKEN) which would otherwise
182183
# 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
184184
if ! git fetch upstream-source "+refs/tags/*:refs/tags/*"; then
185185
echo "❌ Failed to fetch tags from '${{inputs.upstream-repo}}'."
186186
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."
187+
if [ -n "${{secrets.PAT}}" ]; then
188+
echo "❌ Ensure that the PAT token has the permission on the repository."
189189
echo "❌ For more information about this token, see the README.md in qcom-build-utils repo."
190190
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."
191+
echo "❌ Make sure the upstream repository is public or if it is private that the PAT token is set and has the necessary permissions."
192192
fi
193193
194194
exit 1
@@ -202,7 +202,7 @@ jobs:
202202
exit 1
203203
fi
204204
205-
- name: Pre-populate the upstream/latest branch if first promotion
205+
- name: Merge upstream tag into upstream/latest
206206
working-directory: ./package-repo
207207
run: |
208208
@@ -214,7 +214,24 @@ jobs:
214214
else
215215
# The branch exists, check it out and promote it to the upstream tag
216216
git checkout upstream/latest
217-
git merge --ff-only ${{inputs.upstream-tag}}
217+
git merge ${{inputs.upstream-tag}}
218+
fi
219+
220+
- name: Strip .github/workflows from upstream/latest
221+
working-directory: ./package-repo
222+
run: |
223+
# Since Github does not allow pushing workflows using the GITHUB_TOKEN, remove .github/workflows if present.
224+
225+
git config user.name "${{vars.DEB_PKG_BOT_CI_NAME}}"
226+
git config user.email "${{vars.DEB_PKG_BOT_CI_EMAIL}}"
227+
228+
git checkout upstream/latest
229+
230+
# Remove .github/workflows/ if present to avoid GITHUB_TOKEN push restrictions.
231+
# The upstream source repo workflows are not relevant to the packaging repo.
232+
if [ -d .github/workflows ]; then
233+
git rm -rf .github/workflows
234+
git commit -s -m "Remove .github/workflows from upstream source"
218235
fi
219236
220237
- name: Merge upstream tag into packaging branch

0 commit comments

Comments
 (0)