Skip to content

Merge pull request #11 from nett00n/bugfix/github-actor-is-not-the-sa… #10

Merge pull request #11 from nett00n/bugfix/github-actor-is-not-the-sa…

Merge pull request #11 from nett00n/bugfix/github-actor-is-not-the-sa… #10

name: Build and Push Docker Image
on:
push:
branches:
- main # Trigger the workflow on pushes to the main branch
jobs:
build:
runs-on: ubuntu-latest
steps:
# Step 1: Check out the repository
- name: Checkout code
uses: actions/checkout@v3
# Step 2: Set up Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# Step 3: Build Docker Image (for all cases, including forks)
- name: Build Docker Image
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: false # Don't push, just build
tags: |
dumbwareio/dumbwhois:latest
dumbwareio/dumbwhois:${{ github.sha }}
dumbwareio/dumbwhois:build-${{ github.run_number }}
platforms: linux/amd64,linux/arm64
push:
runs-on: ubuntu-latest
needs: build
if: github.repository_owner == github.actor || github.repository_owner == 'dumbwareio' # Only push for repository owner, not forks
steps:
# Step 4: Log in to Docker Hub (only for non-forked repositories)
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Step 5: Push Docker Image (only for repository owner)
- name: Push Docker Image
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true # This will push the image to Docker Hub
tags: |
dumbwareio/dumbwhois:latest
dumbwareio/dumbwhois:${{ github.sha }}
dumbwareio/dumbwhois:build-${{ github.run_number }}
platforms: linux/amd64,linux/arm64