Files
opencatd-open/.github/workflows/ci.yaml
2023-05-25 20:48:22 +08:00

57 lines
2.0 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: Docker Image CI
#触发器设置
on:
push:
branches:
- main
- dev
#项目任务,任务之间可以并行调度
jobs:
build:
#选择云端运行的环境
runs-on: ubuntu-latest
steps:
#uses代表使用一个模块此处使用的是checkout模块将github项目文件导入到当前环境中
- uses: actions/checkout@v3
#使用with跟在后面来为前面的模块输入参数
with:
submodules: 'true'
- name: Get current date
id: date
run: echo "::set-output name=today::$(date +'%Y%m%d')"
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
- name: Login to DockerHub
uses: docker/login-action@v2
with:
#这里用到了github的secrets功能避免账户和密码随仓库泄露
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
#导入这个模块来完成自动编译和推送
uses: docker/build-push-action@v3
with:
context: .
file: ./docker/Dockerfile
push: true
#在这里通过加入需要编译的平台和前面配好的QEMUbuildx来达到多平台编译
platforms: linux/amd64,linux/arm64
#指定用户/仓库名
tags: |
${{ github.repository }}:${{ steps.date.outputs.today }}
${{ github.repository }}:${{ contains(github.ref,'main') && 'latest' || github.ref_name }}
- name: Docker Hub Description
#这里是通过md文件自动生成dockerhub描述的模块也可以不需要
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: ${{ github.repository }}
readme-filepath: ./README.md