Skip to content

Commit

Permalink
Don't push/login to docker in forks.
Browse files Browse the repository at this point in the history
  • Loading branch information
sobomax committed Aug 1, 2024
1 parent cc97ee0 commit 6f13c64
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
env:
DOCKER_REPO: sippylabs/webrtc_phone
BASE_IMAGE: sippylabs/rtpproxy:RFC5245_ICE-ubuntu_latest
DOCKER_RW: ${{ ( github.repository == 'sippy/webrtc_phone' && github.event_name != 'pull_request' ) && 'true' || 'false' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -64,7 +65,7 @@ jobs:
uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
if: github.event_name != 'pull_request'
if: ${{ env.DOCKER_RW }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
Expand Down Expand Up @@ -97,7 +98,7 @@ jobs:
context: .
file: ./Dockerfile
build-args: BASE_IMAGE=${{ env.BASE_IMAGE }}
push: true
push: ${{ env.DOCKER_RW }}
tags: |
${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Expand All @@ -106,7 +107,7 @@ jobs:
cache-to: ${{ env.CACHE_SPEC }},mode=max

- name: Update DockerHub repo description
if: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
if: ${{ env.DOCKER_RW }} && ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
Expand Down

0 comments on commit 6f13c64

Please sign in to comment.