Skip to content

Commit ec03714

Browse files
keerthi-gosimonbeaudoin0935
authored andcommitted
fix: switch pull_request_target to pull_request
- Replace pull_request_target with pull_request to prevent fork PRs from running with elevated permissions and secret access - Remove conditional fork-safe checkout; use single actions/checkout@v4 - Fix upload condition to trigger on push/schedule/workflow_dispatch only - Add packages: write permission required for GHCR push Signed-off-by: Keerthi Gowda <kbalehal@qti.qualcomm.com>
1 parent 0574378 commit ec03714

File tree

3 files changed

+54
-34
lines changed

3 files changed

+54
-34
lines changed

.github/actions/build_container/action.yml

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Builds the container and chroots
22
description: |
3-
This Github Actions builds the container and sets up the chroot environment for building packages for noble and questing.
3+
This Github Action builds the containers and sets up the chroot environment for building packages for noble and questing.
44
55
inputs:
66

@@ -29,20 +29,3 @@ runs:
2929
- name: Build noble and questing containers
3030
shell: bash
3131
run: ./docker_deb_build.py --rebuild --no-update-check
32-
33-
- name: Push to GHCR
34-
if: ${{inputs.push-to-ghcr}} == 'true'
35-
shell: bash
36-
run: |
37-
echo ${{inputs.token}} | docker login ghcr.io -u ${{inputs.username}} --password-stdin
38-
39-
# UBUNTU IMAGES
40-
docker push ghcr.io/${{env.QCOM_ORG_NAME}}/${{env.IMAGE_NAME}}:${{inputs.arch}}-noble
41-
docker push ghcr.io/${{env.QCOM_ORG_NAME}}/${{env.IMAGE_NAME}}:${{inputs.arch}}-questing
42-
docker push ghcr.io/${{env.QCOM_ORG_NAME}}/${{env.IMAGE_NAME}}:${{inputs.arch}}-resolute
43-
44-
# DEBIAN IMAGES
45-
docker push ghcr.io/${{env.QCOM_ORG_NAME}}/${{env.IMAGE_NAME}}:${{inputs.arch}}-trixie
46-
docker push ghcr.io/${{env.QCOM_ORG_NAME}}/${{env.IMAGE_NAME}}:${{inputs.arch}}-sid
47-
48-
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Uploads the containers
2+
description: |
3+
This Github Action uploads the built containers.
4+
5+
inputs:
6+
7+
arch:
8+
description: The architecture to build for. Ex amd64, arm64, etc
9+
required: true
10+
11+
push-to-ghcr:
12+
description: Whether to push the built image to GitHub Container Registry
13+
required: true
14+
default: "true"
15+
16+
token:
17+
description: PAT token
18+
required: true
19+
20+
username:
21+
description: Username for the PAT token
22+
required: true
23+
24+
runs:
25+
using: "composite"
26+
27+
steps:
28+
29+
- name: Push to GHCR
30+
if: ${{ inputs.push-to-ghcr == 'true' }}
31+
shell: bash
32+
run: |
33+
echo ${{inputs.token}} | docker login ghcr.io -u ${{inputs.username}} --password-stdin
34+
35+
# UBUNTU IMAGES
36+
docker push ghcr.io/${{env.QCOM_ORG_NAME}}/${{env.IMAGE_NAME}}:${{inputs.arch}}-noble
37+
docker push ghcr.io/${{env.QCOM_ORG_NAME}}/${{env.IMAGE_NAME}}:${{inputs.arch}}-questing
38+
docker push ghcr.io/${{env.QCOM_ORG_NAME}}/${{env.IMAGE_NAME}}:${{inputs.arch}}-resolute
39+
40+
# DEBIAN IMAGES
41+
docker push ghcr.io/${{env.QCOM_ORG_NAME}}/${{env.IMAGE_NAME}}:${{inputs.arch}}-trixie
42+
docker push ghcr.io/${{env.QCOM_ORG_NAME}}/${{env.IMAGE_NAME}}:${{inputs.arch}}-sid

.github/workflows/qcom-container-build-and-upload.yml

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
name: Container Build And Upload
22
description: |
33
Builds and uploads to GHCR (GitHub Container Registry) the container used to build the Qualcomm debian packages.
4-
This workflow will assumes the build architecture is amd64 (x86_64) since the github's 'ubuntu-latest' runs-on tag
5-
is used. Using docker's buildx, the Dockerfile in this repo's docker/ folder will be built for amd64 and cross-compiled
6-
for arm64.
4+
Builds natively on an arm64 self-hosted runner. Images are uploaded on push to main, scheduled runs, and manual dispatches.
75
86
on:
97
schedule:
108
# Runs at 00:00 UTC every Monday
119
- cron: '0 0 * * 1'
1210

13-
pull_request_target:
11+
pull_request:
1412
branches:
1513
- main
1614
paths:
@@ -30,6 +28,7 @@ on:
3028

3129
permissions:
3230
contents: read
31+
packages: write
3332

3433
env:
3534
QCOM_ORG_NAME: "qualcomm-linux"
@@ -45,24 +44,20 @@ jobs:
4544
runs-on: ubuntu-24.04-arm
4645
steps:
4746

48-
# PRs from forks (pull_request_target): check out the PR's fork + exact commit
49-
- name: Checkout PR head (fork-safe)
50-
if: ${{ github.event_name == 'pull_request_target' }}
51-
uses: actions/checkout@v4
52-
with:
53-
repository: ${{ github.event.pull_request.head.repo.full_name }}
54-
ref: ${{ github.event.pull_request.head.sha }}
55-
persist-credentials: false
56-
57-
# Push / schedule / manual: normal checkout
5847
- name: Checkout repository
59-
if: ${{ github.event_name != 'pull_request_target' }}
6048
uses: actions/checkout@v4
6149

6250
- name: Build Images
6351
uses: ./.github/actions/build_container
6452
with:
6553
arch: arm64
66-
push-to-ghcr: ${{ github.event_name != 'pull_request_target' }}
54+
55+
- name: Upload Images
56+
uses: ./.github/actions/upload_containers
57+
# Only upload on trusted events that land code on main
58+
if: ${{ github.event_name == 'schedule' || github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
59+
with:
60+
arch: arm64
61+
push-to-ghcr: "true"
6762
token: ${{ secrets.DEB_PKG_BOT_CI_TOKEN }}
6863
username: ${{ vars.DEB_PKG_BOT_CI_USERNAME }}

0 commit comments

Comments
 (0)