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
This commit is contained in:
1 parent
8514df985b
commit
8d450c69d2
2 files changed
+38
-6
No files matched your search
@@ -1,17 +1,23 @@
|
|||||||
name: "[PR] Cleanup Docker preview image"
|
name: "[PR] Cleanup Docker preview image"
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request_target:
|
||||||
types: [closed]
|
types: [closed]
|
||||||
branches:
|
branches:
|
||||||
- dev
|
- dev
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
pr-number:
|
||||||
|
description: "PR number whose preview image to delete"
|
||||||
|
required: true
|
||||||
|
type: number
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
packages: write
|
packages: write
|
||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: ghcr.io
|
REGISTRY: ghcr.io
|
||||||
IMAGE_TAG: pr-${{ github.event.number }}
|
IMAGE_TAG: pr-${{ github.event.inputs.pr-number || github.event.number }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
delete-image:
|
delete-image:
|
||||||
|
|||||||
@@ -2,9 +2,20 @@ name: "[PR] Publish Docker preview image"
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
types: [opened, synchronize, reopened]
|
types: [opened, synchronize, reopened, ready_for_review]
|
||||||
branches:
|
branches:
|
||||||
- dev
|
- 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:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
@@ -17,18 +28,33 @@ env:
|
|||||||
TURBO_TELEMETRY_DISABLED: 1
|
TURBO_TELEMETRY_DISABLED: 1
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: pr-docker-${{ github.event.number }}
|
group: pr-docker-${{ github.event.inputs.pr-number || github.event.number }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-push:
|
build-and-push:
|
||||||
name: Build and push PR preview image
|
name: Build and push PR preview image
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 20
|
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:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
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
|
- name: Docker meta
|
||||||
id: meta
|
id: meta
|
||||||
@@ -36,7 +62,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
images: "${{ env.GHCR_REPO }}"
|
images: "${{ env.GHCR_REPO }}"
|
||||||
tags: |
|
tags: |
|
||||||
type=raw,value=pr-${{ github.event.number }}
|
type=raw,value=${{ steps.tag.outputs.tag }}
|
||||||
|
|
||||||
- name: Log in to the Container registry
|
- name: Log in to the Container registry
|
||||||
uses: docker/login-action@v4
|
uses: docker/login-action@v4
|
||||||
|
|||||||
Reference in new issue
Block a user