1 Star 0 Fork 133

苏州景臻智汇科技有限公司/yangfan

forked from test-instructor/yangfan 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
CI.yml 14.61 KB
一键复制 编辑 原始数据 按行查看 历史
chen Ander 提交于 2023-06-13 11:04 . Update CI.yml
name: CI
on:
push:
branches:
- main
- dev
tags:
- '*'
env:
REGISTRY: yangfanz/
ALIYUN_REGISTRY: registry.cn-hangzhou.aliyuncs.com/yangfanz/
IMAGE_NAME_SERVER: server
IMAGE_NAME_TIMER: timer
IMAGE_NAME_MASTER: master
IMAGE_NAME_WORK: work
IMAGE_NAME_WEB: web
IMAGE_NAME_RUN: run
IMAGE_TAG: v1.${{ github.run_number }}
jobs:
server:
name: Building a server image
runs-on: ubuntu-latest
steps:
- name: Determine image_tag and image_suffix
id: determine
run: |
if [[ ${{ github.event_name }} == 'push' && ${{ github.ref }} =~ ^refs/tags/.* ]]; then
image_tag=$(echo "${{ github.ref }}" | sed -e 's|^refs/tags/||')
image_suffix=''
else
image_tag=${{ env.IMAGE_TAG }}
image_suffix='-debug'
fi
echo "::set-output name=image_tag::${image_tag}"
echo "::set-output name=image_suffix::${image_suffix}"
- uses: actions/checkout@v3
- name: Login to Docker Container Registry
uses: docker/login-action@v1
with:
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Build and push Docker image
run: |
docker build -t server -f server/Dockerfile .
docker tag server ${{ env.REGISTRY }}${{ env.IMAGE_NAME_SERVER }}${{ steps.determine.outputs.image_suffix }}:${{ steps.determine.outputs.image_tag }}
docker push ${{ env.REGISTRY }}${{ env.IMAGE_NAME_SERVER }}${{ steps.determine.outputs.image_suffix }}:${{ steps.determine.outputs.image_tag }}
docker tag server ${{ env.REGISTRY }}${{ env.IMAGE_NAME_SERVER }}${{ steps.determine.outputs.image_suffix }}:latest
docker push ${{ env.REGISTRY }}${{ env.IMAGE_NAME_SERVER }}${{ steps.determine.outputs.image_suffix }}:latest
- name: Login to Aliyun Container Registry
uses: docker/login-action@v1
with:
registry: ${{ env.ALIYUN_REGISTRY }}${{ env.IMAGE_NAME_SERVER }}
username: ${{ secrets.ALIYUN_REGISTRY_USERNAME }}
password: ${{ secrets.ALIYUN_REGISTRY_PASSWORD }}
- name: Push to Aliyun Docker image
run: |
docker tag server ${{ env.ALIYUN_REGISTRY }}${{ env.IMAGE_NAME_SERVER }}${{ steps.determine.outputs.image_suffix }}:${{ steps.determine.outputs.image_tag }}
docker push ${{ env.ALIYUN_REGISTRY }}${{ env.IMAGE_NAME_SERVER }}${{ steps.determine.outputs.image_suffix }}:${{ steps.determine.outputs.image_tag }}
docker tag server ${{ env.ALIYUN_REGISTRY }}${{ env.IMAGE_NAME_SERVER }}${{ steps.determine.outputs.image_suffix }}:latest
docker push ${{ env.ALIYUN_REGISTRY }}${{ env.IMAGE_NAME_SERVER }}${{ steps.determine.outputs.image_suffix }}:latest
timer:
name: Building a timer image
runs-on: ubuntu-latest
steps:
- name: Determine image_tag and image_suffix
id: determine
run: |
if [[ ${{ github.event_name }} == 'push' && ${{ github.ref }} =~ ^refs/tags/.* ]]; then
image_tag=$(echo "${{ github.ref }}" | sed -e 's|^refs/tags/||')
image_suffix=''
else
image_tag=${{ env.IMAGE_TAG }}
image_suffix='-debug'
fi
echo "::set-output name=image_tag::${image_tag}"
echo "::set-output name=image_suffix::${image_suffix}"
- uses: actions/checkout@v3
- name: Login to Docker Container Registry
uses: docker/login-action@v1
with:
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Build and push Docker image
run: |
docker build -t timer -f timer/Dockerfile .
docker tag timer ${{ env.REGISTRY }}${{ env.IMAGE_NAME_TIMER }}${{ steps.determine.outputs.image_suffix }}:${{ steps.determine.outputs.image_tag }}
docker push ${{ env.REGISTRY }}${{ env.IMAGE_NAME_TIMER }}${{ steps.determine.outputs.image_suffix }}:${{ steps.determine.outputs.image_tag }}
docker tag timer ${{ env.REGISTRY }}${{ env.IMAGE_NAME_TIMER }}${{ steps.determine.outputs.image_suffix }}:latest
docker push ${{ env.REGISTRY }}${{ env.IMAGE_NAME_TIMER }}${{ steps.determine.outputs.image_suffix }}:latest
- name: Login to Aliyun Container Registry
uses: docker/login-action@v1
with:
registry: ${{ env.ALIYUN_REGISTRY }}${{ env.IMAGE_NAME_TIMER }}
username: ${{ secrets.ALIYUN_REGISTRY_USERNAME }}
password: ${{ secrets.ALIYUN_REGISTRY_PASSWORD }}
- name: Push to Aliyun Docker image
run: |
docker tag timer ${{ env.ALIYUN_REGISTRY }}${{ env.IMAGE_NAME_TIMER }}${{ steps.determine.outputs.image_suffix }}:${{ steps.determine.outputs.image_tag }}
docker push ${{ env.ALIYUN_REGISTRY }}${{ env.IMAGE_NAME_TIMER }}${{ steps.determine.outputs.image_suffix }}:${{ steps.determine.outputs.image_tag }}
docker tag timer ${{ env.ALIYUN_REGISTRY }}${{ env.IMAGE_NAME_TIMER }}${{ steps.determine.outputs.image_suffix }}:latest
docker push ${{ env.ALIYUN_REGISTRY }}${{ env.IMAGE_NAME_TIMER }}${{ steps.determine.outputs.image_suffix }}:latest
master:
name: Building a master image
runs-on: ubuntu-latest
steps:
- name: Determine image_tag and image_suffix
id: determine
run: |
if [[ ${{ github.event_name }} == 'push' && ${{ github.ref }} =~ ^refs/tags/.* ]]; then
image_tag=$(echo "${{ github.ref }}" | sed -e 's|^refs/tags/||')
image_suffix=''
else
image_tag=${{ env.IMAGE_TAG }}
image_suffix='-debug'
fi
echo "::set-output name=image_tag::${image_tag}"
echo "::set-output name=image_suffix::${image_suffix}"
- uses: actions/checkout@v3
- name: Login to Docker Container Registry
uses: docker/login-action@v1
with:
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Build and push Docker image
run: |
docker build -t master -f master/Dockerfile .
docker tag master ${{ env.REGISTRY }}${{ env.IMAGE_NAME_MASTER }}${{ steps.determine.outputs.image_suffix }}:${{ steps.determine.outputs.image_tag }}
docker push ${{ env.REGISTRY }}${{ env.IMAGE_NAME_MASTER }}${{ steps.determine.outputs.image_suffix }}:${{ steps.determine.outputs.image_tag }}
docker tag master ${{ env.REGISTRY }}${{ env.IMAGE_NAME_MASTER }}${{ steps.determine.outputs.image_suffix }}:latest
docker push ${{ env.REGISTRY }}${{ env.IMAGE_NAME_MASTER }}${{ steps.determine.outputs.image_suffix }}:latest
- name: Login to Aliyun Container Registry
uses: docker/login-action@v1
with:
registry: ${{ env.ALIYUN_REGISTRY }}${{ env.IMAGE_NAME_MASTER }}
username: ${{ secrets.ALIYUN_REGISTRY_USERNAME }}
password: ${{ secrets.ALIYUN_REGISTRY_PASSWORD }}
- name: Push to Aliyun Docker image
run: |
docker tag master ${{ env.ALIYUN_REGISTRY }}${{ env.IMAGE_NAME_MASTER }}${{ steps.determine.outputs.image_suffix }}:${{ steps.determine.outputs.image_tag }}
docker push ${{ env.ALIYUN_REGISTRY }}${{ env.IMAGE_NAME_MASTER }}${{ steps.determine.outputs.image_suffix }}:${{ steps.determine.outputs.image_tag }}
docker tag master ${{ env.ALIYUN_REGISTRY }}${{ env.IMAGE_NAME_MASTER }}${{ steps.determine.outputs.image_suffix }}:latest
docker push ${{ env.ALIYUN_REGISTRY }}${{ env.IMAGE_NAME_MASTER }}${{ steps.determine.outputs.image_suffix }}:latest
work:
name: Building a work image
runs-on: ubuntu-latest
steps:
- name: Determine image_tag and image_suffix
id: determine
run: |
if [[ ${{ github.event_name }} == 'push' && ${{ github.ref }} =~ ^refs/tags/.* ]]; then
image_tag=$(echo "${{ github.ref }}" | sed -e 's|^refs/tags/||')
image_suffix=''
else
image_tag=${{ env.IMAGE_TAG }}
image_suffix='-debug'
fi
echo "::set-output name=image_tag::${image_tag}"
echo "::set-output name=image_suffix::${image_suffix}"
- uses: actions/checkout@v3
- name: Login to Docker Container Registry
uses: docker/login-action@v1
with:
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Build and push Docker image
run: |
docker build -t work -f work/Dockerfile .
docker tag work ${{ env.REGISTRY }}${{ env.IMAGE_NAME_WORK }}${{ steps.determine.outputs.image_suffix }}:${{ steps.determine.outputs.image_tag }}
docker push ${{ env.REGISTRY }}${{ env.IMAGE_NAME_WORK }}${{ steps.determine.outputs.image_suffix }}:${{ steps.determine.outputs.image_tag }}
docker tag work ${{ env.REGISTRY }}${{ env.IMAGE_NAME_WORK }}${{ steps.determine.outputs.image_suffix }}:latest
docker push ${{ env.REGISTRY }}${{ env.IMAGE_NAME_WORK }}${{ steps.determine.outputs.image_suffix }}:latest
- name: Login to Aliyun Container Registry
uses: docker/login-action@v1
with:
registry: ${{ env.ALIYUN_REGISTRY }}${{ env.IMAGE_NAME_WORK }}
username: ${{ secrets.ALIYUN_REGISTRY_USERNAME }}
password: ${{ secrets.ALIYUN_REGISTRY_PASSWORD }}
- name: Push to Aliyun Docker image
run: |
docker tag work ${{ env.ALIYUN_REGISTRY }}${{ env.IMAGE_NAME_WORK }}${{ steps.determine.outputs.image_suffix }}:${{ steps.determine.outputs.image_tag }}
docker push ${{ env.ALIYUN_REGISTRY }}${{ env.IMAGE_NAME_WORK }}${{ steps.determine.outputs.image_suffix }}:${{ steps.determine.outputs.image_tag }}
docker tag work ${{ env.ALIYUN_REGISTRY }}${{ env.IMAGE_NAME_WORK }}${{ steps.determine.outputs.image_suffix }}:latest
docker push ${{ env.ALIYUN_REGISTRY }}${{ env.IMAGE_NAME_WORK }}${{ steps.determine.outputs.image_suffix }}:latest
run:
name: Building a run image
runs-on: ubuntu-latest
steps:
- name: Determine image_tag and image_suffix
id: determine
run: |
if [[ ${{ github.event_name }} == 'push' && ${{ github.ref }} =~ ^refs/tags/.* ]]; then
image_tag=$(echo "${{ github.ref }}" | sed -e 's|^refs/tags/||')
image_suffix=''
else
image_tag=${{ env.IMAGE_TAG }}
image_suffix='-debug'
fi
echo "::set-output name=image_tag::${image_tag}"
echo "::set-output name=image_suffix::${image_suffix}"
- uses: actions/checkout@v3
- name: Login to Docker Container Registry
uses: docker/login-action@v1
with:
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Build and push Docker image
run: |
docker build -t run -f run/Dockerfile .
docker tag run ${{ env.REGISTRY }}${{ env.IMAGE_NAME_RUN }}${{ steps.determine.outputs.image_suffix }}:${{ steps.determine.outputs.image_tag }}
docker push ${{ env.REGISTRY }}${{ env.IMAGE_NAME_RUN }}${{ steps.determine.outputs.image_suffix }}:${{ steps.determine.outputs.image_tag }}
docker tag run ${{ env.REGISTRY }}${{ env.IMAGE_NAME_RUN }}${{ steps.determine.outputs.image_suffix }}:latest
docker push ${{ env.REGISTRY }}${{ env.IMAGE_NAME_RUN }}${{ steps.determine.outputs.image_suffix }}:latest
- name: Login to Aliyun Container Registry
uses: docker/login-action@v1
with:
registry: ${{ env.ALIYUN_REGISTRY }}${{ env.IMAGE_NAME_RUN }}
username: ${{ secrets.ALIYUN_REGISTRY_USERNAME }}
password: ${{ secrets.ALIYUN_REGISTRY_PASSWORD }}
- name: Push to Aliyun Docker image
run: |
docker tag run ${{ env.ALIYUN_REGISTRY }}${{ env.IMAGE_NAME_RUN }}${{ steps.determine.outputs.image_suffix }}:${{ steps.determine.outputs.image_tag }}
docker push ${{ env.ALIYUN_REGISTRY }}${{ env.IMAGE_NAME_RUN }}${{ steps.determine.outputs.image_suffix }}:${{ steps.determine.outputs.image_tag }}
docker tag run ${{ env.ALIYUN_REGISTRY }}${{ env.IMAGE_NAME_RUN }}${{ steps.determine.outputs.image_suffix }}:latest
docker push ${{ env.ALIYUN_REGISTRY }}${{ env.IMAGE_NAME_RUN }}${{ steps.determine.outputs.image_suffix }}:latest
web:
name: Building a web image
runs-on: ubuntu-latest
steps:
- name: Determine image_tag and image_suffix
id: determine
run: |
if [[ ${{ github.event_name }} == 'push' && ${{ github.ref }} =~ ^refs/tags/.* ]]; then
image_tag=$(echo "${{ github.ref }}" | sed -e 's|^refs/tags/||')
image_suffix=''
else
image_tag=${{ env.IMAGE_TAG }}
image_suffix='-debug'
fi
echo "::set-output name=image_tag::${image_tag}"
echo "::set-output name=image_suffix::${image_suffix}"
- uses: actions/checkout@v3
- name: Login to Docker Container Registry
uses: docker/login-action@v1
with:
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Build and push Docker image
run: |
docker build -t web -f ./web/Dockerfile .
docker tag web ${{ env.REGISTRY }}${{ env.IMAGE_NAME_WEB }}${{ steps.determine.outputs.image_suffix }}:${{ steps.determine.outputs.image_tag }}
docker push ${{ env.REGISTRY }}${{ env.IMAGE_NAME_WEB }}${{ steps.determine.outputs.image_suffix }}:${{ steps.determine.outputs.image_tag }}
docker tag web ${{ env.REGISTRY }}${{ env.IMAGE_NAME_WEB }}${{ steps.determine.outputs.image_suffix }}:latest
docker push ${{ env.REGISTRY }}${{ env.IMAGE_NAME_WEB }}${{ steps.determine.outputs.image_suffix }}:latest
- name: Login to Aliyun Container Registry
uses: docker/login-action@v1
with:
registry: ${{ env.ALIYUN_REGISTRY }}${{ env.IMAGE_NAME_WEB }}
username: ${{ secrets.ALIYUN_REGISTRY_USERNAME }}
password: ${{ secrets.ALIYUN_REGISTRY_PASSWORD }}
- name: Push to Aliyun Docker image
run: |
docker tag web ${{ env.ALIYUN_REGISTRY }}${{ env.IMAGE_NAME_WEB }}${{ steps.determine.outputs.image_suffix }}:${{ steps.determine.outputs.image_tag }}
docker push ${{ env.ALIYUN_REGISTRY }}${{ env.IMAGE_NAME_WEB }}${{ steps.determine.outputs.image_suffix }}:${{ steps.determine.outputs.image_tag }}
docker tag web ${{ env.ALIYUN_REGISTRY }}${{ env.IMAGE_NAME_WEB }}${{ steps.determine.outputs.image_suffix }}:latest
docker push ${{ env.ALIYUN_REGISTRY }}${{ env.IMAGE_NAME_WEB }}${{ steps.determine.outputs.image_suffix }}:latest
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/izzai/yangfan.git
git@gitee.com:izzai/yangfan.git
izzai
yangfan
yangfan
main

搜索帮助