type
Post
status
Published
date
Jan 5, 2021
slug
2021/01/05/1609813267677
summary
Github Action 获取当前时间并给 docker 镜像打标签
tags
Docker
Github
category
Docker
created days
new update day
icon
password
Created_time
Dec 5, 2022 09:33 AM
Last edited time
Mar 1, 2025 01:50 AM

Github Action 获取当前时间并给 docker 镜像打标签

获取并格式化当前时间

只需在使用到时间变量之前定义以下步骤即可
- name: Get current date id: date run: echo "::set-output name=today::$(date +'%Y-%m-%d')"

给镜像打标签

docker/build-push-action@v2 支持多标签,只需要 tangcuyu/nginx-proxy:${{ steps.date.outputs.today }} 像这样填写即可给镜像打上相应的标签。
- name: Build and push uses: docker/build-push-action@v2 with: context: . file: ./Dockerfile platforms: linux/amd64,linux/arm64/v8,linux/arm/v7,linux/arm/v6 push: ${{ github.event_name != 'pull_request' }} tags: | tangcuyu/nginx-proxy:latest tangcuyu/nginx-proxy:${{ steps.date.outputs.today }}

成果展示

notion image
 
欢迎加入喵星计算机技术研究院,原创技术文章第一时间推送。
notion image
 
Git 常用命令INSTALL CLAMAV ON CENTOS 7