test24 / .github /workflows /docker-deploy.yml
Niansuh's picture
Upload 14 files
381d345 verified
name: Docker Build and Push
on:
push:
branches:
- main # Triggers the workflow when changes are pushed to the 'main' branch
pull_request:
branches:
- main # Optional: Trigger on pull requests to 'main' for testing
jobs:
build:
runs-on: ubuntu-latest
steps:
# Step 1: Check out the repository
- name: Checkout code
uses: actions/checkout@v3 # Check out your GitHub repository
# Step 2: Set up Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2 # Set up Docker Buildx to support advanced features like multi-platform builds
with:
install: true
# Step 3: Log in to Docker Hub
- name: Log in to Docker Hub
uses: docker/login-action@v2 # Logs in to Docker Hub
with:
username: ${{ secrets.DOCKER_USERNAME }} # Your Docker Hub username stored as a GitHub secret
password: ${{ secrets.DOCKER_PASSWORD }} # Your Docker Hub password stored as a GitHub secret
# Step 4: Build and push the Docker image
- name: Build and Push Docker Image
uses: docker/build-push-action@v5 # Build and push the Docker image
with:
context: . # The context is the root of your repository
push: true # Automatically push the image after building
tags: ${{ secrets.DOCKER_USERNAME }}/blackboxv2:v786 # Replace 'your-app-name' with your desired Docker image name
# Step 5: Log out of Docker Hub
- name: Log out of Docker Hub
run: docker logout