Skip to content

Add combined DTB image tooling and DTB-agnostic GRUB configuration #174

Add combined DTB image tooling and DTB-agnostic GRUB configuration

Add combined DTB image tooling and DTB-agnostic GRUB configuration #174

name: Container Build And Upload
description: |
Builds and uploads to GHCR (GitHub Container Registry) the container used to build the Qualcomm debian packages.
This workflow will assumes the build architecture is amd64 (x86_64) since the github's 'ubuntu-latest' runs-on tag
is used. Using docker's buildx, the Dockerfile in this repo's docker/ folder will be built for amd64 and cross-compiled
for arm64.
on:
schedule:
# Runs at 00:00 UTC every Monday
- cron: '0 0 * * 1'
pull_request_target:
branches:
- main
- development
push:
branches:
- main
workflow_dispatch:
permissions:
contents: read
security-events: write
env:
QCOM_ORG_NAME: "qualcomm-linux"
IMAGE_NAME: "pkg-builder"
jobs:
# Check if this PR changes files in the docker/ folder. If not, there is no point in building and pushing a new image.
check-if-build-needed:
runs-on: ubuntu-latest
outputs:
build-needed: ${{ steps.set-output.outputs.build-needed }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{github.head_ref}}
fetch-depth: 0
- name: Check if build is needed
id: set-output
run: |
echo "build-needed=false" >> $GITHUB_OUTPUT
if [[ "${{ github.event_name }}" == "pull_request_target" ]]; then
CHANGED_FILES=$(git diff --name-only origin/main...HEAD)
echo "Changed files: $CHANGED_FILES"
if [[ $CHANGED_FILES == *"docker/"* ]]; then
echo "Build IS needed as docker/ folder changed."
echo "build-needed=true" >> $GITHUB_OUTPUT
else
echo "Build is NOT needed as docker/ folder did not change."
echo "build-needed=false" >> $GITHUB_OUTPUT
fi
elif [[ "${{ github.event_name }}" == "push" ]]; then
CHANGED_FILES=$(git diff --name-only ${{ github.event.before }}..${{ github.event.after }})
echo "Changed files: $CHANGED_FILES"
if [[ $CHANGED_FILES == *".github/docker/"* ]]; then
echo "Build IS needed as .github/docker/ folder changed."
echo "build-needed=true" >> $GITHUB_OUTPUT
else
echo "Build is NOT needed as .github/docker/ folder did not change."
echo "build-needed=false" >> $GITHUB_OUTPUT
fi
elif [[ "${{ github.event_name }}" == "schedule" || "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "Build is needed for schedule or workflow_dispatch or schedule."
echo "build-needed=true" >> $GITHUB_OUTPUT
else
echo "Unrecognized event: ${{ github.event_name }}. Failing the build."
exit 1
fi
# Build the amd64 natively on ubuntu-latest which is an x86_64 host
build-image-amd64:
needs: check-if-build-needed
if: needs.check-if-build-needed.outputs.build-needed == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout qcom-build-utils
uses: actions/checkout@v4
with:
ref: ${{github.head_ref}}
- name: Build Images
uses: ./.github/actions/build_container
with:
arch: amd64
push-to-ghcr: ${{ github.event_name != 'pull_request_target' }}
token: ${{ secrets.DEB_PKG_BOT_CI_TOKEN }}
username: ${{ vars.DEB_PKG_BOT_CI_USERNAME }}
# Build the arm64 natively using a self-hosted runner on an arm64 host
# Cross compiling the image using buildx on an x86_64 host was tried but failed due to
# issues with qemu and multiarch support in docker buildx.
build-image-arm64:
needs: check-if-build-needed
if: needs.check-if-build-needed.outputs.build-needed == 'true'
runs-on: ["self-hosted", "lecore-prd-u2404-arm64-xlrg-od-ephem"]
steps:
- name: Checkout Dockerfile
uses: actions/checkout@v4
with:
ref: ${{github.head_ref}}
- name: Build Images
uses: ./.github/actions/build_container
with:
arch: arm64
push-to-ghcr: ${{ github.event_name != 'pull_request_target' }}
token: ${{ secrets.DEB_PKG_BOT_CI_TOKEN }}
username: ${{ vars.DEB_PKG_BOT_CI_USERNAME }}