-
Notifications
You must be signed in to change notification settings - Fork 16
153 lines (129 loc) · 4.8 KB
/
build-engine.yml
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: Build Engine
on:
workflow_dispatch:
inputs:
solution:
required: true
type: choice
options:
- text-generation-webui-gpu
- text-generation-webui-cpu
- comfyui
target:
description: 'Target'
required: true
type: choice
options:
- develop
- stage
- testnet
env:
IMAGE_FILE: ''
IMAGE_RESOURCE: ''
SOLUTION: ${{ inputs.solution }}
PR_REPO_ARGO: super-protocol/argocd-clusters
DOCKERFILE: ''
DOCKERFILE_CONTEXT: ''
SUBMODULE_PATH: ''
TARGET: ${{ inputs.target }}
jobs:
build-engine:
runs-on: self-hosted
permissions:
contents: read
packages: write
repository-projects: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Prepare variables
run: |
if [[ "$SOLUTION" == text-generation-webui* ]]; then
DOCKERFILE="./Text Generation WebUI/Dockerfile"
DOCKERFILE_CONTEXT="./Text Generation WebUI/"
SUBMODULE_PATH="Text\ Generation\ WebUI/text-generation-webui"
if [[ "$SOLUTION" == *cpu ]]; then
BUILD_ARGS="--build-arg GPU_CHOICE=N"
elif [[ "$SOLUTION" == *gpu ]]; then
BUILD_ARGS="--build-arg GPU_CHOICE=A"
fi
elif [ "$SOLUTION" == "comfyui" ]; then
DOCKERFILE="./ComfyUI/Dockerfile"
DOCKERFILE_CONTEXT="./ComfyUI/"
SUBMODULE_PATH="ComfyUI/ComfyUI"
else
echo "Invalid solution name"
exit 1
fi
echo "DOCKERFILE=$DOCKERFILE" >> $GITHUB_ENV
echo "DOCKERFILE_CONTEXT=$DOCKERFILE_CONTEXT" >> $GITHUB_ENV
echo "SUBMODULE_PATH=$SUBMODULE_PATH" >> $GITHUB_ENV
echo "BUILD_ARGS=$BUILD_ARGS" >> $GITHUB_ENV
- name: Checkout git submodules
run: |
git submodule init && git submodule update "$SUBMODULE_PATH"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
buildkitd-flags: --debug
driver-opts: |
image=moby/buildkit:v0.12.0
- name: Create .env file
run: |
cd "$DOCKERFILE_CONTEXT"
if [ "$TARGET" == "develop" ]; then
echo "${{ secrets.DEVELOP_SOLUTION_ENV_BASE64 }}" | base64 --decode > .env
elif [ "$TARGET" == "stage" ]; then
echo "${{ secrets.STAGING_SOLUTION_ENV_BASE64 }}" | base64 --decode > .env
elif [ "$TARGET" == "testnet" ]; then
echo "${{ secrets.TESTNET_SOLUTION_ENV_BASE64 }}" | base64 --decode > .env
else
echo "Invalid instance: $TARGET"
exit 1
fi
- name: Build Docker image and save to file
run: |
IMAGE_FILE="$SOLUTION-image-b${{ github.run_id }}.tar.gz"
echo "docker build -t $SOLUTION:latest -f $DOCKERFILE $(echo $BUILD_ARGS) $DOCKERFILE_CONTEXT"
docker build -t $SOLUTION:latest -f "$DOCKERFILE" $(echo $BUILD_ARGS) "$DOCKERFILE_CONTEXT"
docker save $SOLUTION:latest | gzip > $IMAGE_FILE
echo "IMAGE_FILE=$IMAGE_FILE" >> $GITHUB_ENV
- name: Set SPCTL repository type
run: |
if [ "$TARGET" == "develop" || "$TARGET" == "stage" ]; then
SPCTL_REPOSITORY_TYPE=private
else
SPCTL_REPOSITORY_TYPE=public
fi
echo "SPCTL_REPOSITORY_TYPE=$SPCTL_REPOSITORY_TYPE" >> $GITHUB_ENV
- name: Download and install SPCTL
uses: Super-Protocol/sp-build-tools/actions/download-spctl@v1
with:
version: latest
repository: ${{ env.SPCTL_REPOSITORY_TYPE }}
gh_token: ${{ secrets.GHFG_TOKEN_SPCTL_RELEASES_DOWNLOAD }}
- name: Prepare SPCTL config
run: |
if [ "$TARGET" == "develop" ]; then
SPCTL_CONFIG="${{ secrets.DEVELOP_SPCTL_CONFIG_BASE64 }}"
elif [ "$TARGET" == "stage" ]; then
SPCTL_CONFIG="${{ secrets.STAGING_SPCTL_CONFIG_BASE64 }}"
elif [ "$TARGET" == "testnet" ]; then
SPCTL_CONFIG="${{ secrets.TESTNET_SPCTL_CONFIG_BASE64 }}"
fi
echo "$SPCTL_CONFIG" | base64 --decode > ./config.json
./spctl --version
- name: Encrypt and upload image
id: upload_image
uses: Super-Protocol/sp-build-tools/actions/upload-file@v1
with:
file_to_upload: ${{ env.IMAGE_FILE }}
- name: Update argocd
uses: Super-Protocol/sp-build-tools/actions/update-argocd@v1
with:
gh_token: ${{ secrets.TOKEN_FOR_ARGOCD_REPO }}
target: ${{ inputs.target }}
resource_type: solution
resource_file: ${{ steps.upload_image.outputs.resource }}
solution_name: ${{ env.SOLUTION }}
commit_type: pull-request