54 lines
1.9 KiB
YAML
54 lines
1.9 KiB
YAML
name: Egg Server 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@v4
|
|
- 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:
|
|
registry: micr.cloud.mioffice.cn
|
|
username: ${{ secrets.MI_DOCKER_USERNAME }}
|
|
password: ${{ secrets.MI_DOCKER_PASSWORD }}
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
push: true
|
|
tags: micr.cloud.mioffice.cn/egg/egg_server:${{ github.sha }}
|
|
|
|
refresh-image:
|
|
runs-on: ubuntu-latest
|
|
container: catthehacker/ubuntu:act-latest
|
|
steps:
|
|
- name: Login to the server and refresh the image
|
|
uses: appleboy/ssh-action@master
|
|
with:
|
|
host: ${{ secrets.SERVER_HOST }}
|
|
username: ${{ secrets.SERVER_USERNAME }}
|
|
key: ${{ secrets.SERVER_KEY }}
|
|
port: ${{ secrets.SERVER_PORT }}
|
|
script: |
|
|
docker pull micr.cloud.mioffice.cn/egg/egg_server:${{ github.sha }}
|
|
docker push micr.cloud.mioffice.cn/egg/egg_server:${{ github.sha }}
|
|
docker rmi $(docker images | grep "micr.cloud.mioffice.cn/egg/egg_server" | grep -v "${{ github.sha }}" | awk '{print $3}')
|
|
|
|
fast-deploy:
|
|
runs-on: ubuntu-latest
|
|
container: cr.d.xiaomi.net/bigdata-fe/matrix-cli
|
|
steps:
|
|
- name: Set matrix-cli config
|
|
run: matrix-cli config set --access-key ${{ secrets.MATRIX_AK }} --secret-key ${{ secrets.MATRIX_SK }}
|
|
- name: Use matrix-cli to deploy
|
|
run: matrix-cli deploy --project 462609 --deploy-space egg-server-prev --reason "${{ github.event.head_commit.message }}" --deploy-percentage 1 --tag ${{ github.sha }}
|