mirror of
https://github.com/RayLabsHQ/gitea-mirror.git
synced 2026-03-14 06:23:01 +03:00
Skip GHCR push for fork PRs
This commit is contained in:
6
.github/workflows/README.md
vendored
6
.github/workflows/README.md
vendored
@@ -30,15 +30,17 @@ This workflow runs on all branches and pull requests. It:
|
|||||||
|
|
||||||
### Docker Build and Push (`docker-build.yml`)
|
### Docker Build and Push (`docker-build.yml`)
|
||||||
|
|
||||||
This workflow builds and pushes Docker images to GitHub Container Registry (ghcr.io), but only when changes are merged to the main branch.
|
This workflow builds Docker images on pushes and pull requests, and pushes to GitHub Container Registry (ghcr.io) when permissions allow (main/tags and same-repo PRs).
|
||||||
|
|
||||||
**When it runs:**
|
**When it runs:**
|
||||||
- On push to the main branch
|
- On push to the main branch
|
||||||
- On tag creation (v*)
|
- On tag creation (v*)
|
||||||
|
- On pull requests (build + scan; push only for same-repo PRs)
|
||||||
|
|
||||||
**Key features:**
|
**Key features:**
|
||||||
- Builds multi-architecture images (amd64 and arm64)
|
- Builds multi-architecture images (amd64 and arm64)
|
||||||
- Pushes images only on main branch, not for PRs
|
- Pushes images for main/tags and same-repo PRs
|
||||||
|
- Skips registry push for fork PRs (avoids package write permission failures)
|
||||||
- Uses build caching to speed up builds
|
- Uses build caching to speed up builds
|
||||||
- Creates multiple tags for each image (latest, semver, sha)
|
- Creates multiple tags for each image (latest, semver, sha)
|
||||||
|
|
||||||
|
|||||||
6
.github/workflows/docker-build.yml
vendored
6
.github/workflows/docker-build.yml
vendored
@@ -55,6 +55,7 @@ jobs:
|
|||||||
driver-opts: network=host
|
driver-opts: network=host
|
||||||
|
|
||||||
- name: Log into registry
|
- name: Log into registry
|
||||||
|
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ${{ env.REGISTRY }}
|
||||||
@@ -105,7 +106,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
push: true
|
push: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
@@ -128,13 +129,14 @@ jobs:
|
|||||||
|
|
||||||
# Wait for image to be available in registry
|
# Wait for image to be available in registry
|
||||||
- name: Wait for image availability
|
- name: Wait for image availability
|
||||||
|
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
|
||||||
run: |
|
run: |
|
||||||
echo "Waiting for image to be available in registry..."
|
echo "Waiting for image to be available in registry..."
|
||||||
sleep 5
|
sleep 5
|
||||||
|
|
||||||
# Add comment to PR with image details
|
# Add comment to PR with image details
|
||||||
- name: Comment PR with image tag
|
- name: Comment PR with image tag
|
||||||
if: github.event_name == 'pull_request'
|
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
|
||||||
uses: actions/github-script@v7
|
uses: actions/github-script@v7
|
||||||
with:
|
with:
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|||||||
Reference in New Issue
Block a user