zhaoyingbo 35bd784e6a
Some checks failed
CI Monitor CI/CD / build-image (push) Successful in 33s
CI Monitor MIflow / build-image (push) Successful in 37s
CI Monitor CI/CD / deploy (push) Failing after 1m5s
chore: 修改项目名
2024-07-26 09:20:53 +00:00

61 lines
2.1 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: CI Monitor CI/CD
on:
push:
branches:
- master
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/gitlab_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/gitlab_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/gitlab_monitor
sed -i "s/sha/${{ github.sha }}/g" docker-compose.yml
docker compose up -d --force-recreate --no-deps gitlab_monitor