🔨 复写厂商品牌删除按钮 🎨 新的标题显示方案 🔨 设备资产速查 #9
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI for Docker Hub | |
on: | |
push: | |
tags: | |
- v* | |
env: | |
# 设置 docker 镜像名 | |
IMAGE_NAME: cat | |
jobs: | |
push: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Build image | |
run: docker build . --file Dockerfile --tag $IMAGE_NAME | |
- name: Log into registry | |
run: echo "${{ secrets.ACCESS_TOKEN }}" | docker login -u celaraze --password-stdin | |
- name: Push image | |
run: | | |
# 拼接镜像 id,这个镜像 id 就是在使用 docker 镜像时 pull 后面的名字。 | |
IMAGE_ID=celaraze/$IMAGE_NAME | |
# 将所有的大写字母转为小写 | |
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | |
# 从 GitHub.ref 中取出版本 | |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | |
# 从 tag 名字中替换 v 字符 | |
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') | |
# 如果当前的分支是 dev,那么将镜像标签设置为 dev | |
[[ "${{ github.ref }}" == "refs/heads/dev" ]] && VERSION=dev | |
# Use Docker `latest` tag convention | |
# [ "$VERSION" == "main" ] && VERSION=latest | |
echo IMAGE_ID=$IMAGE_ID | |
echo VERSION=$VERSION | |
# 推送 v* 标签的镜像 | |
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION | |
docker push $IMAGE_ID:$VERSION | |
# 推送 latest 标签的镜像 | |
docker tag $IMAGE_NAME $IMAGE_ID:latest | |
docker push $IMAGE_ID:latest |