Skip to content

Build and Push Docker Image #1

Build and Push Docker Image

Build and Push Docker Image #1

name: Build and Push Docker Image
on:
workflow_dispatch: # Allow manual runs too
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the repo
- name: Checkout code
uses: actions/checkout@v4
# Step 2: Log in to Docker Hub
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Step 3: Set up Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Step 4: Build and push the image
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/gh-demo:latest