update action
This commit is contained in:
44
.github/workflows/ci.yaml
vendored
44
.github/workflows/ci.yaml
vendored
@@ -1,54 +1,66 @@
|
||||
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')"
|
||||
run: echo "today=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
id: buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Cache Docker layers
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: /tmp/.buildx-cache
|
||||
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-buildx-
|
||||
|
||||
- name: Available platforms
|
||||
run: echo ${{ steps.buildx.outputs.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 }}
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Build and push
|
||||
#导入这个模块来完成自动编译和推送
|
||||
uses: docker/build-push-action@v3
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
file: ./docker/Dockerfile
|
||||
push: true
|
||||
#在这里通过加入需要编译的平台和前面配好的QEMU,buildx来达到多平台编译
|
||||
platforms: linux/amd64,linux/arm64
|
||||
#指定用户/仓库名
|
||||
tags: |
|
||||
${{ github.repository }}:${{ steps.date.outputs.today }}
|
||||
${{ github.repository }}:${{ contains(github.ref,'main') && 'latest' || github.ref_name }}
|
||||
cache-from: type=local,src=/tmp/.buildx-cache
|
||||
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
|
||||
|
||||
- name: Move cache
|
||||
run: |
|
||||
rm -rf /tmp/.buildx-cache
|
||||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
||||
|
||||
- name: Docker Hub Description
|
||||
#这里是通过md文件自动生成dockerhub描述的模块,也可以不需要
|
||||
uses: peter-evans/dockerhub-description@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
|
||||
46
.github/workflows/tag.yaml
vendored
46
.github/workflows/tag.yaml
vendored
@@ -1,53 +1,65 @@
|
||||
name: Docker Image CI
|
||||
#触发器设置
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
#项目任务,任务之间可以并行调度
|
||||
jobs:
|
||||
|
||||
build:
|
||||
#选择云端运行的环境
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
#uses代表使用一个模块,此处使用的是checkout模块,将github项目文件导入到当前环境中
|
||||
- uses: actions/checkout@v3
|
||||
#使用with跟在后面来为前面的模块输入参数
|
||||
with:
|
||||
submodules: 'true'
|
||||
- name: Get version # 获取 Tag Version
|
||||
|
||||
- name: Get version
|
||||
id: vars
|
||||
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
|
||||
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
id: buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Cache Docker layers
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: /tmp/.buildx-cache
|
||||
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-buildx-
|
||||
|
||||
- name: Available platforms
|
||||
run: echo ${{ steps.buildx.outputs.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 }}
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Build and push
|
||||
#导入这个模块来完成自动编译和推送
|
||||
uses: docker/build-push-action@v3
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
file: ./docker/Dockerfile
|
||||
push: true
|
||||
#在这里通过加入需要编译的平台和前面配好的QEMU,buildx来达到多平台编译
|
||||
platforms: linux/amd64,linux/arm64
|
||||
#指定用户/仓库名
|
||||
tags: |
|
||||
${{ github.repository }}:${{ steps.vars.outputs.tag }}
|
||||
${{ github.repository }}:latest
|
||||
cache-from: type=local,src=/tmp/.buildx-cache
|
||||
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
|
||||
|
||||
- name: Move cache
|
||||
run: |
|
||||
rm -rf /tmp/.buildx-cache
|
||||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
||||
|
||||
- name: Docker Hub Description
|
||||
#这里是通过md文件自动生成dockerhub描述的模块,也可以不需要
|
||||
uses: peter-evans/dockerhub-description@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
|
||||
Reference in New Issue
Block a user