Open TheNeg0t1ator opened 9 months ago
Create a file named .github/workflows/docker-build.yml
in your repository to define the GitHub Actions workflow.
name: Build Docker Image
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Build Docker Image
run: docker build -t your-image-name:latest .
This workflow is triggered on pushes to the main branch, checks out the repository, and builds the Docker image using the specified Dockerfile.
Configure Docker Hub Secrets:
Go to your GitHub repository, navigate to "Settings" > "Secrets," and add two secrets: DOCKER_USERNAME
and DOCKER_PASSWORD
.
DOCKER_USERNAME
: Your Docker Hub username.DOCKER_PASSWORD
: Your Docker Hub password or a personal access token.Now, when you push changes to the main branch, GitHub Actions will automatically build the Docker image and use the provided secrets to authenticate and push the image.
Part of:
9
[ ] Use Yaml to automatically package