Skip to content

Update docker-build.yml #3

Update docker-build.yml

Update docker-build.yml #3

Workflow file for this run

name: Build and Push Docker Image
on:
push:
branches:
- main # 你可以根据需要更改触发条件,如 `main` 分支
jobs:
build:
runs-on: ubuntu-latest
steps:
# 1. 检出代码
- name: Checkout repository
uses: actions/checkout@v3
# 2. 设置 Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# 3. 登录 Docker Hub
- name: Log in to Docker Hub
uses: docker/#-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }} # 你的 Docker Hub 用户名
password: ${{ secrets.DOCKER_PASSWORD }} # 你的 Docker Hub 密码
# 4. 构建 Docker 镜像
- name: Build Docker image
run: |
docker build -t ${{ secrets.DOCKER_USERNAME }}/your-image-name:latest .
# 5. 推送 Docker 镜像到 Docker Hub
- name: Push Docker image
run: |
docker push ${{ secrets.DOCKER_USERNAME }}/your-image-name:latest