Compare commits

...
Author SHA1 Message Date
Thomas 4b5774ec74 Merge branch 'dev' into pr-container-images 2026-07-14 17:24:32 +02:00
ajnart 8d450c69d2 fix(ci): fork-safe cleanup, manual triggers, draft PR skipping
- cleanup: pull_request -> pull_request_target so fork PRs trigger cleanup
- cleanup: add workflow_dispatch for manual stale image deletion
- publish: skip fork PRs (no packages:write) and draft PRs
- publish: add ready_for_review trigger
- publish: add workflow_dispatch for manual fork PR builds
- publish: unified tag derivation step
2026-07-11 15:41:06 +02:00
ajnart 8514df985b fix(ci): use separate homarr-test package with pr-<N> tag 2026-07-11 13:21:20 +02:00
ajnart 28d7a75b63 fix(ci): use homarr-test-pr- tag prefix instead of pr- 2026-07-11 12:19:27 +02:00
ajnart 97a661d04f fix(ci): apply CodeRabbit review fixes
- Rename tag prefix from omar-test-pr- to pr-
- Add contents: read permission to publish workflow
- Disable persist-credentials on checkout step
2026-07-11 12:17:47 +02:00
ajnart 3a1bd4e969 style: auto-fix lint and format 2026-07-11 10:03:45 +00:00
ajnart d8f831093e feat(ci): add PR Docker preview image publish and cleanup workflows 2026-07-11 12:01:56 +02:00
2 changed files with 153 additions and 0 deletions

No files matched your search

@@ -0,0 +1,64 @@
name: "[PR] Cleanup Docker preview image"
on:
pull_request_target:
types: [closed]
branches:
- dev
workflow_dispatch:
inputs:
pr-number:
description: "PR number whose preview image to delete"
required: true
type: number
permissions:
packages: write
env:
REGISTRY: ghcr.io
IMAGE_TAG: pr-${{ github.event.inputs.pr-number || github.event.number }}
jobs:
delete-image:
name: Delete PR preview image from GHCR
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Delete package version
uses: actions/github-script@v8
with:
script: |
const packageName = 'homarr-test';
const org = context.repo.owner;
const tag = process.env.IMAGE_TAG;
const versions = await github.paginate(
github.rest.packages.getAllPackageVersionsForPackageOwnedByOrg,
{
package_type: 'container',
package_name: packageName,
org,
per_page: 100,
}
);
const target = versions.find(v =>
v.metadata?.container?.tags?.includes(tag)
);
if (!target) {
console.log(`No package version found with tag "${tag}". Nothing to delete.`);
return;
}
console.log(`Deleting package version ${target.id} (tag: ${tag})`);
await github.rest.packages.deletePackageVersionForOrg({
package_type: 'container',
package_name: packageName,
org,
package_version_id: target.id,
});
console.log(`Successfully deleted package version ${target.id}`);
@@ -0,0 +1,89 @@
name: "[PR] Publish Docker preview image"
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches:
- dev
workflow_dispatch:
inputs:
pr-number:
description: "PR number (uses head ref of that PR)"
required: true
type: number
ref:
description: "Git ref to build (branch, tag, or SHA)"
required: false
type: string
default: ""
permissions:
contents: read
packages: write
env:
SKIP_ENV_VALIDATION: true
REGISTRY: ghcr.io
GHCR_REPO: ghcr.io/homarr-labs/homarr-test
TURBO_TELEMETRY_DISABLED: 1
concurrency:
group: pr-docker-${{ github.event.inputs.pr-number || github.event.number }}
cancel-in-progress: true
jobs:
build-and-push:
name: Build and push PR preview image
runs-on: ubuntu-latest
timeout-minutes: 25
if: |
github.event_name == 'workflow_dispatch' ||
(
github.event_name == 'pull_request' &&
github.event.pull_request.draft == false &&
github.event.pull_request.head.repo.full_name == github.repository
)
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
ref: ${{ github.event.inputs.ref || '' }}
- name: Determine tag
id: tag
run: |
PR_NUMBER="${{ github.event.inputs.pr-number || github.event.number }}"
echo "tag=pr-${PR_NUMBER}" >> "$GITHUB_OUTPUT"
echo "pr-number=${PR_NUMBER}" >> "$GITHUB_OUTPUT"
- name: Docker meta
id: meta
uses: docker/metadata-action@v6
with:
images: "${{ env.GHCR_REPO }}"
tags: |
type=raw,value=${{ steps.tag.outputs.tag }}
- name: Log in to the Container registry
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Build and push
uses: docker/build-push-action@v7
with:
context: .
network: host
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
env:
SKIP_ENV_VALIDATION: true