ci: 新增CICD
This commit is contained in:
parent
3773e11505
commit
e8257ff1e9
57
.gitea/workflows/cicd.yaml
Normal file
57
.gitea/workflows/cicd.yaml
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
name: CI Monitor CI/CD
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-image:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container: catthehacker/ubuntu:act-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v2
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
registry: git.yingbo.im:333
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v4
|
||||||
|
with:
|
||||||
|
push: true
|
||||||
|
tags: git.yingbo.im:333/zhaoyingbo/ci_monitor:${{ github.sha }}
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
needs: build-image
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container: catthehacker/ubuntu:act-latest
|
||||||
|
steps:
|
||||||
|
# 检出代码
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
# 使用scp命令将docker-compose.yml文件上传到服务器
|
||||||
|
- name: Upload docker-compose.yml to server
|
||||||
|
uses: appleboy/scp-action@master
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.SERVER_HOST }}
|
||||||
|
username: ${{ secrets.SERVER_USERNAME }}
|
||||||
|
key: ${{ secrets.SERVER_KEY }}
|
||||||
|
port: ${{ secrets.SERVER_PORT }}
|
||||||
|
source: docker-compose.yml
|
||||||
|
target: /home/${{ secrets.SERVER_USERNAME }}/docker/ci_monitor
|
||||||
|
# 登录服务器,执行docker-compose命令
|
||||||
|
- name: Login to the server and execute docker-compose command
|
||||||
|
uses: appleboy/ssh-action@master
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.SERVER_HOST }}
|
||||||
|
username: ${{ secrets.SERVER_USERNAME }}
|
||||||
|
key: ${{ secrets.SERVER_KEY }}
|
||||||
|
port: ${{ secrets.SERVER_PORT }}
|
||||||
|
script: |
|
||||||
|
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} git.yingbo.im:333
|
||||||
|
cd /home/${{ secrets.SERVER_USERNAME }}/docker/ci_monitor
|
||||||
|
sed -i "s/sha/${{ github.sha }}/g" docker-compose.yml
|
||||||
|
docker compose up -d --force-recreate --no-deps ci_monitor
|
13
Dockerfile
Normal file
13
Dockerfile
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
FROM micr.cloud.mioffice.cn/zhaoyingbo/bun:alpine-cn
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY package*.json ./
|
||||||
|
|
||||||
|
COPY bun.lockb ./
|
||||||
|
|
||||||
|
RUN bun install
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
CMD ["bun", "start"]
|
7
docker-compose.yml
Normal file
7
docker-compose.yml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
version: "3"
|
||||||
|
|
||||||
|
services:
|
||||||
|
ci_monitor:
|
||||||
|
image: git.yingbo.im:333/zhaoyingbo/ci_monitor:sha
|
||||||
|
container_name: ci_monitor
|
||||||
|
restart: always
|
Loading…
x
Reference in New Issue
Block a user