[buildbot] ci: add support for testing PR containers
LEDE Commits
lede-commits at lists.infradead.org
Sun Jan 11 09:07:27 PST 2026
ynezz pushed a commit to buildbot.git, branch main:
https://git.openwrt.org/93918cc2e2257ae8838166d2baad30617295df4e
commit 93918cc2e2257ae8838166d2baad30617295df4e
Author: Petr Štetiar <ynezz at true.cz>
AuthorDate: Sun Jan 11 10:25:00 2026 +0100
ci: add support for testing PR containers
Enable PR container publishing to GHCR with pr-<number> tags so that
containers can be manually tested before merging. Add cleanup workflow
to automatically delete PR containers when the PR is closed.
Signed-off-by: Petr Štetiar <ynezz at true.cz>
---
.github/workflows/build-push.yml | 21 +++++++++++++++++--
.github/workflows/cleanup-pr-containers.yml | 32 +++++++++++++++++++++++++++++
2 files changed, 51 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/build-push.yml b/.github/workflows/build-push.yml
index 16b66e0..31f3920 100644
--- a/.github/workflows/build-push.yml
+++ b/.github/workflows/build-push.yml
@@ -6,6 +6,12 @@ on:
tags:
- 'v*'
pull_request:
+ workflow_dispatch:
+ inputs:
+ pr_number:
+ description: 'PR number to build and push container for'
+ required: true
+ type: number
env:
BUILDBOT_VERSION: 3.11.8
@@ -28,6 +34,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout at v5
+ with:
+ ref: ${{ github.event_name == 'workflow_dispatch' && format('refs/pull/{0}/merge', inputs.pr_number) || '' }}
- uses: actions/setup-python at v5
with:
@@ -64,6 +72,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout at v5
+ with:
+ ref: ${{ github.event_name == 'workflow_dispatch' && format('refs/pull/{0}/merge', inputs.pr_number) || '' }}
- name: Environment variables
run: |
@@ -88,7 +98,7 @@ jobs:
deploy:
name: Push Container
- if: github.event_name != 'pull_request' || github.repository_owner != 'openwrt'
+ if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
needs: build-test
@@ -106,6 +116,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout at v5
+ with:
+ ref: ${{ github.event_name == 'workflow_dispatch' && format('refs/pull/{0}/merge', inputs.pr_number) || '' }}
- name: Environment variables
run: |
@@ -115,7 +127,12 @@ jobs:
id: meta
uses: docker/metadata-action at v5
with:
- images: name=ghcr.io/${{ github.repository }}/build${{ matrix.container_flavor }}-v${{ env.BUILDBOT_VERSION }}
+ images: ghcr.io/${{ github.repository }}/build${{ matrix.container_flavor }}-v${{ env.BUILDBOT_VERSION }}
+ tags: |
+ type=raw,value=pr-${{ inputs.pr_number }},enable=${{ github.event_name == 'workflow_dispatch' }}
+ type=ref,event=branch
+ type=sha,prefix=sha-,enable=${{ github.event_name != 'workflow_dispatch' }}
+ type=semver,pattern={{version}}
- name: Login to GitHub Container Registry
uses: docker/login-action at v3
diff --git a/.github/workflows/cleanup-pr-containers.yml b/.github/workflows/cleanup-pr-containers.yml
new file mode 100644
index 0000000..073b4b8
--- /dev/null
+++ b/.github/workflows/cleanup-pr-containers.yml
@@ -0,0 +1,32 @@
+name: Cleanup PR Containers
+
+on:
+ pull_request:
+ types: [closed]
+
+env:
+ BUILDBOT_VERSION: 3.11.8
+
+jobs:
+ cleanup:
+ name: Delete PR container images
+ runs-on: ubuntu-latest
+ permissions:
+ packages: write
+
+ strategy:
+ matrix:
+ container_flavor:
+ - master
+ - worker
+
+ steps:
+ - name: Delete PR container image
+ uses: actions/delete-package-versions at v5
+ with:
+ package-name: buildbot/build${{ matrix.container_flavor }}-v${{ env.BUILDBOT_VERSION }}
+ package-type: container
+ delete-only-pre-release-versions: false
+ min-versions-to-keep: 0
+ delete-only-untagged-versions: false
+ version-pattern: pr-${{ github.event.pull_request.number }}
More information about the lede-commits
mailing list