Skip to content

Commit

Permalink
Create docker-build.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
MemoryCollection authored Nov 15, 2024
1 parent c4666d6 commit 1a4dc27
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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 密码 (存储在 GitHub Secrets)

# 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

0 comments on commit 1a4dc27

Please # to comment.