Skip to content

Commit 1238f14

Browse files
authored
Update docker-build.yml
1 parent 72cc8f1 commit 1238f14

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

.github/workflows/docker-build.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,21 @@ on:
55
branches:
66
- development
77
tags:
8-
- "v*" # Triggers on version tags like v1.0.0
8+
- "v*"
99
pull_request:
1010
branches:
1111
- main
12-
workflow_dispatch: # Allow manual trigger
12+
workflow_dispatch:
1313

1414
jobs:
1515
build:
1616
runs-on: ubuntu-latest
1717

18+
permissions:
19+
contents: read
20+
packages: write # notwendig für GHCR push
21+
pull-requests: read
22+
1823
steps:
1924
- name: Checkout code
2025
uses: actions/checkout@v3
@@ -23,16 +28,17 @@ jobs:
2328
uses: docker/setup-buildx-action@v2
2429

2530
- name: Log in to GitHub Container Registry
31+
if: github.event.pull_request.head.repo.full_name == github.repository # verhindert push bei externen PRs
2632
uses: docker/login-action@v2
2733
with:
2834
registry: ghcr.io
2935
username: ${{ github.actor }}
3036
password: ${{ secrets.GITHUB_TOKEN }}
31-
37+
3238
- name: Build and push Docker image
3339
uses: docker/build-push-action@v5
3440
with:
35-
push: ${{ github.event_name != 'pull_request' }}
41+
push: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
3642
tags: |
3743
ghcr.io/${{ github.repository_owner }}/react-ardublockly-backend:latest
3844
ghcr.io/${{ github.repository_owner }}/react-ardublockly-backend:${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || github.ref_name }}

0 commit comments

Comments
 (0)