Skip to content

Commit

Permalink
If Docker CI Changes, then Run the CI for Docker in PR
Browse files Browse the repository at this point in the history
  • Loading branch information
calvinp0 committed Feb 11, 2024
1 parent 1626c3b commit c2ead23
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/docker_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ on:
paths:
- "./Dockerfile"
- "./.github/workflows/docker_build.yml"
types: [opened, synchronize, reopened, ready_for_review, review_requested]


jobs:
build:
Expand All @@ -39,8 +41,9 @@ jobs:

# Conditional step for building image without pushing, for PRs
- name: Build Docker Image (No Push)
if: github.event_name == 'pull_request'
uses: docker/build-push-action@v2
# if condition is pull request or push then it will build the image
if: github.event_name == 'pull_request' || github.event_name == 'push'
uses: docker/[email protected]
with:
context: .
file: ./Dockerfile
Expand All @@ -49,18 +52,18 @@ jobs:
# Conditional steps for building and pushing, for pushes to main
- name: Login to Docker Hub
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: docker/login-action@v1
uses: docker/login-action@v3.0.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up Docker Buildx
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v3.0.0

- name: Build and Push Docker Image
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5.1.0
with:
context: .
file: ./Dockerfile
Expand Down

0 comments on commit c2ead23

Please sign in to comment.