58 lines
2.0 KiB
Plaintext

name: Egg Gitlab CR 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:
file: ./docker/deploy/Dockerfile
push: true
tags: ${{ env.DOCKER_IMAGE }}:${{ 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 ${{ env.DOCKER_IMAGE }}:${{ github.sha }}
docker push ${{ env.DOCKER_IMAGE }}:${{ github.sha }}
docker rmi $(docker images | grep "${{ env.DOCKER_IMAGE }}" | 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-gitlab-cr-prev --reason "${{ github.event.head_commit.message }}" --deploy-percentage 1 --tag ${{ github.sha }}
env:
DOCKER_IMAGE: micr.cloud.mioffice.cn/egg/replace_me