Skip to content

Commit ad33ce2

Browse files
refactor(.gitea/.github): 简化CI/CD流程,优化Docker镜像构建与推送
1 parent 046b594 commit ad33ce2

2 files changed

Lines changed: 44 additions & 51 deletions

File tree

.gitea/workflows/.gitea.yml

Lines changed: 27 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,34 @@
11
kind: pipeline
22
name: Build and Push Docker Image to Gitea Container Registry
33

4-
trigger:
5-
event:
6-
- push
7-
branch:
8-
- main
9-
10-
jobs:
11-
build:
12-
steps:
13-
- name: checkout
14-
image: alpine/git
15-
commands:
16-
- git clone --depth 1 ${CI_REPO} .
4+
steps:
5+
- name: checkout
6+
image: alpine/git
7+
commands:
8+
- git clone --depth 1 ${CI_REPO} .
179

18-
- name: setup-buildx
19-
image: docker:23
20-
privileged: true
21-
commands:
22-
- docker buildx create --use
10+
- name: setup-buildx
11+
image: docker:23
12+
privileged: true
13+
commands:
14+
- docker buildx create --use
2315

24-
- name: build-docker-image
25-
image: docker:23
26-
commands:
27-
- docker buildx build --file ./Dockerfile --tag ${CI_REGISTRY}/comfy_container_ui/c_c_u:latest .
16+
- name: build-docker-image
17+
image: docker:23
18+
commands:
19+
- docker buildx build --file ./Dockerfile --tag ${CI_REGISTRY}/comfy_container_ui/c_c_u:latest .
2820

29-
push:
30-
needs: [build]
31-
steps:
32-
- name: login-to-registry
33-
image: docker:23
34-
environment:
35-
DOCKER_PASSWORD:
36-
from_secret: PACKAGE_GITEA_TOKEN
37-
commands:
38-
- echo "${DOCKER_PASSWORD}" | docker login ${CI_REGISTRY} -u "${CI_AUTHOR}" --password-stdin
21+
- name: push-docker-image
22+
image: docker:23
23+
environment:
24+
DOCKER_PASSWORD:
25+
from_secret: package_gitea_token
26+
commands:
27+
- echo "${package_gitea_token}" | docker login ${CI_REGISTRY} -u "${CI_COMMITTER}" --password-stdin
28+
- docker push ${CI_REGISTRY}/comfy_container_ui/c_c_u:latest
3929

40-
- name: push-docker-image
41-
image: docker:23
42-
commands:
43-
- docker push ${CI_REGISTRY}/comfy_container_ui/c_c_u:latest
30+
trigger:
31+
event:
32+
- push
33+
branch:
34+
- main

.github/workflows/github.yml

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,31 @@ jobs:
1111
runs-on: ubuntu-latest
1212

1313
steps:
14+
# 检出代码
1415
- name: Checkout code
1516
uses: actions/checkout@v3
1617

18+
# 设置 Docker Buildx
1719
- name: Set up Docker Buildx
1820
uses: docker/setup-buildx-action@v2
1921

20-
- name: Build Docker image
21-
run: |
22-
docker buildx create --use
23-
docker buildx build --file ./Dockerfile --tag ghcr.io/inknight-dednet/comfy_container_ui/c_c_u:latest --load.
24-
25-
push:
26-
runs-on: ubuntu-latest
27-
needs: build
28-
29-
steps:
22+
# 登录到 GitHub Container Registry
3023
- name: Login to GitHub Container Registry
3124
uses: docker/login-action@v2
3225
with:
3326
registry: ghcr.io
34-
username: ${{ github.actor }}
35-
password: ${{ secrets.TOKEN }}
27+
username: ${{ github.actor }} # GitHub 用户名
28+
password: ${{ secrets.TOKEN }} # GitHub 自动生成的令牌
29+
30+
# 添加调试步骤
31+
- name: Test Network Connection
32+
run: curl -I https://download.pytorch.org/whl/rocm6.2
3633

37-
- name: Push Docker image to GitHub Container Registry
38-
run: |
39-
docker push ghcr.io/inknight-dednet/comfy_container_ui/c_c_u:latest
34+
# 构建并推送 Docker 镜像
35+
- name: Build and push Docker image to GitHub Container Registry
36+
uses: docker/build-push-action@v3
37+
with:
38+
context: . # 当前目录作为构建上下文
39+
file: ./Dockerfile # Dockerfile 路径
40+
push: true # 推送镜像
41+
tags: ghcr.io/inknight-dednet/comfy_container_ui/c_c_u:latest # 镜像推送到 GitHub 包注册表

0 commit comments

Comments
 (0)