Skip to content

feat(monitoring, public): enhance metrics logging and display #78

feat(monitoring, public): enhance metrics logging and display

feat(monitoring, public): enhance metrics logging and display #78

Workflow file for this run

name: Docker
on:
push:
branches:
- main
tags:
- v*
paths-ignore:
- 'lankong_tools/**'
- '*.md'
- '.github/**'
env:
IMAGE_NAME: random-api-go
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23'
- name: Build for amd64
run: |
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -o bin/amd64/random-api .
- name: Build for arm64
run: |
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -a -installsuffix cgo -o bin/arm64/random-api .
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: woodchen
password: ${{ secrets.ACCESS_TOKEN }}
- name: Build and push multi-arch image
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.run
push: true
tags: woodchen/${{ env.IMAGE_NAME }}:latest
platforms: linux/amd64,linux/arm64
- name: Create artifact
run: |
zip -r public.zip public
- name: Deploy public directory to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: root
key: ${{ secrets.SERVER_SSH_KEY }}
source: 'public.zip'
target: '/tmp'
- name: Execute deployment commands
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: root
key: ${{ secrets.SERVER_SSH_KEY }}
script: |
# 解压文件
unzip -o /tmp/public.zip -d /tmp/public_temp
# 删除目标目录中的现有文件
rm -rf /opt/1panel/docker/compose/random-api-go/public/*
# 移动新文件到目标目录
mv -f /tmp/public_temp/public/* /opt/1panel/docker/compose/random-api-go/public/
# 设置目录及其子文件的所有权和权限
chmod -R 0755 /opt/1panel/docker/compose/random-api-go/public
# 清理临时文件
rm /tmp/public.zip
rm -rf /tmp/public_temp
# 拉取镜像
docker pull woodchen/random-api-go:latest
# 停止并删除容器
docker stop random-api-go || true
docker rm random-api-go || true
# 启动容器
docker compose -f /opt/1panel/docker/compose/random-api-go/docker-compose.yml up -d