File size: 1,529 Bytes
adee7c5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b8221ca
adee7c5
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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:v12  # 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