Build and Push Docker Image #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Pipeline to build and push Docker image to Docker Hub when there are changes in the main branch | |
# Going to use actions from -> https://github.com/marketplace?query=docker | |
name: Docker Build and Push Docker Image | |
run-name: Build and Push Docker Image | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
docker: | |
name: Build and Push Docker Image | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout the code | |
- name: Checkout | |
uses: actions/checkout@v4 | |
# Ubuntu-latest has Docker pre-installed | |
# Login to Docker Hub | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{secrets.DOCKER_USERNAME}} # Docker Hub username | |
password: ${{secrets.DOCKER_PASSWORD}} # Docker Hub password | |
# Build the Docker image | |
- name: Build & Push the Docker Image | |
uses: docker/build-push-action@v6 | |
with: | |
push: true | |
tags: itzzjb/docker-react:latest |