Skip to content

Commit 70a1158

Browse files
committed
修改部分bug
1 parent 8043608 commit 70a1158

69 files changed

Lines changed: 2492 additions & 324 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/settings.local.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(git add:*)",
5+
"Bash(gh run:*)",
6+
"Bash(git commit:*)",
7+
"Bash(git push:*)"
8+
]
9+
}
10+
}

.claude/worktrees/agent-a1fa4ae0

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 8043608a7bb39f6438c8af876a5005db019e2de9

.claude/worktrees/agent-a24240fc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 8043608a7bb39f6438c8af876a5005db019e2de9

.claude/worktrees/agent-a255c7c4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 8043608a7bb39f6438c8af876a5005db019e2de9

.claude/worktrees/agent-aaece09b

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 8043608a7bb39f6438c8af876a5005db019e2de9

.github/workflows/docker.yml

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ env:
1212
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
1313
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME || secrets.DOCKER_HUB_USERNAME }}
1414
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN || secrets.DOCKERHUB_PASSWORD || secrets.DOCKER_HUB_ACCESS_TOKEN }}
15+
TEST_SERVER_HOST: ${{ secrets.TEST_SERVER_HOST || '72.31.92.61' }}
16+
TEST_SERVER_USER: ${{ secrets.TEST_SERVER_USER || 'xisoul' }}
1517

1618
jobs:
1719
build:
@@ -41,6 +43,7 @@ jobs:
4143
password: ${{ secrets.GITHUB_TOKEN }}
4244

4345
- name: Login to Docker Hub
46+
if: ${{ env.DOCKERHUB_USERNAME != '' && env.DOCKERHUB_TOKEN != '' }}
4447
uses: docker/login-action@v3
4548
with:
4649
username: ${{ env.DOCKERHUB_USERNAME }}
@@ -54,15 +57,15 @@ jobs:
5457
else
5558
TAG="${GITHUB_SHA::7}"
5659
fi
57-
echo "TAG=$TAG" >> $GITHUB_OUTPUT
60+
echo "TAG=$TAG" >> "$GITHUB_OUTPUT"
5861
5962
- name: Docker metadata
6063
id: meta
6164
uses: docker/metadata-action@v5
6265
with:
6366
images: |
6467
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
65-
docker.io/${{ env.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}
68+
${{ env.DOCKERHUB_USERNAME != '' && format('docker.io/{0}/{1}', env.DOCKERHUB_USERNAME, env.IMAGE_NAME) || '' }}
6669
tags: |
6770
type=ref,event=branch
6871
type=semver,pattern={{version}}
@@ -78,7 +81,8 @@ jobs:
7881
push: true
7982
build-args: |
8083
SOURCE_COMMIT=${{ steps.image_tag.outputs.TAG }}
81-
PYTHON_IMAGE=3.11-slim
84+
PYTHON_IMAGE=3.11
85+
VARIANT=-slim
8286
tags: ${{ steps.meta.outputs.tags }}
8387
labels: ${{ steps.meta.outputs.labels }}
8488
cache-from: type=gha
@@ -93,37 +97,58 @@ jobs:
9397
- name: Check deploy configuration
9498
id: deploy_config
9599
env:
96-
TEST_SERVER_HOST: ${{ secrets.TEST_SERVER_HOST }}
97-
TEST_SERVER_USER: ${{ secrets.TEST_SERVER_USER }}
98100
TEST_SERVER_PASSWORD: ${{ secrets.TEST_SERVER_PASSWORD }}
99101
run: |
100-
if [[ -n "$TEST_SERVER_HOST" && -n "$TEST_SERVER_USER" && -n "$TEST_SERVER_PASSWORD" ]]; then
102+
if [[ -n "$TEST_SERVER_PASSWORD" ]]; then
101103
echo "enabled=true" >> "$GITHUB_OUTPUT"
102104
else
103105
echo "enabled=false" >> "$GITHUB_OUTPUT"
104-
echo "Test server secrets are not configured; skipping deployment."
106+
echo "Test server password is not configured; skipping deployment."
105107
fi
106108
107109
- name: Deploy via SSH
108110
if: steps.deploy_config.outputs.enabled == 'true'
109111
uses: appleboy/ssh-action@v1
110112
with:
111-
host: ${{ secrets.TEST_SERVER_HOST }}
112-
username: ${{ secrets.TEST_SERVER_USER }}
113+
host: ${{ env.TEST_SERVER_HOST }}
114+
username: ${{ env.TEST_SERVER_USER }}
113115
password: ${{ secrets.TEST_SERVER_PASSWORD }}
114116
script: |
115117
set -e
116118
117-
IMAGE="ghcr.io/${{ github.repository_owner }}/nonebot-webui:${{ needs.build.outputs.image_tag }}"
119+
docker_cmd() {
120+
if docker info >/dev/null 2>&1; then
121+
docker "$@"
122+
else
123+
sudo docker "$@"
124+
fi
125+
}
126+
127+
for path in \
128+
/home/xisoul/nonebot-webui-data \
129+
/home/xisoul/nonebot-webui-data/projects \
130+
/home/xisoul/nonebot-webui-external-projects
131+
do
132+
if [[ ! -d "$path" ]]; then
133+
sudo mkdir -p "$path"
134+
fi
135+
done
118136
119-
# Pull the image built in this workflow run
120-
docker pull "$IMAGE"
137+
for file in \
138+
/home/xisoul/nonebot-webui-data/config.json \
139+
/home/xisoul/nonebot-webui-data/project.json
140+
do
141+
if [[ ! -f "$file" ]]; then
142+
sudo touch "$file"
143+
fi
144+
sudo chmod 666 "$file"
145+
done
121146
122-
# Stop and remove old container
123-
docker rm -f nonebot-webui 2>/dev/null || true
147+
IMAGE="ghcr.io/${{ github.repository_owner }}/nonebot-webui:${{ needs.build.outputs.image_tag }}"
124148
125-
# Start new container
126-
docker run -d \
149+
docker_cmd pull "$IMAGE"
150+
docker_cmd rm -f nonebot-webui 2>/dev/null || true
151+
docker_cmd run -d \
127152
--name nonebot-webui \
128153
--restart=always \
129154
--network host \
@@ -135,18 +160,15 @@ jobs:
135160
-v /home/xisoul/nonebot-webui-data/project.json:/app/project.json \
136161
"$IMAGE"
137162
138-
# Wait for healthy
139163
echo "Waiting for container to be healthy..."
140164
for i in $(seq 1 30); do
141-
STATUS=$(docker inspect -f '{{if .State.Health}}{{.State.Health.Status}}{{else}}{{.State.Status}}{{end}}' nonebot-webui 2>/dev/null || echo "unknown")
165+
STATUS=$(docker_cmd inspect -f '{{if .State.Health}}{{.State.Health.Status}}{{else}}{{.State.Status}}{{end}}' nonebot-webui 2>/dev/null || echo unknown)
142166
echo " [$i/30] status: $STATUS"
143-
if [ "$STATUS" = "healthy" ]; then
144-
echo "Container is healthy!"
167+
if [[ "$STATUS" == "healthy" ]]; then
145168
exit 0
146169
fi
147170
sleep 2
148171
done
149172
150-
echo "Warning: Container did not become healthy within 60s"
151-
docker logs --tail 20 nonebot-webui
173+
docker_cmd logs --tail 50 nonebot-webui
152174
exit 1

0 commit comments

Comments
 (0)