Skip to content

docker build

docker build #1

Workflow file for this run

name: Build and Push Docker Image to Docker Hub
on:
push:
branches:
- main # Trigger the action when changes are pushed to the main branch
jobs:
build:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the repository
- name: Checkout code
uses: actions/checkout@v2
# Step 2: Set up Docker Buildx (optional but recommended for modern builds)
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# Step 3: Log in to Docker Hub
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Step 4: Build the Docker image
- name: Build Docker image
run: |
docker buildx build -t ${{ secrets.DOCKER_USERNAME }}/cd3:latest .
# Step 5: Push Docker image to Docker Hub
- name: Push Docker image
run: |
docker push ${{ secrets.DOCKER_USERNAME }}/cd3:latest