Skip to content

🎨 update readme

🎨 update readme #1

Workflow file for this run

name: Build Docker Images
on:
push:
tags:
- 'v8.*'
- 'v11.*'
- 'v17.*'
- 'v21.*'
- 'v23.*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('**/Dockerfile') }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push JRE image
run: |
# 获取当前的 Git 标签(例如 v8.x.x,v11.x.x 等)
TAG=${GITHUB_REF##*/}
# 根据标签选择对应的 JRE 版本和 Dockerfile
if [[ "$TAG" == v8* ]]; then
IMAGE_TAG="jre8"
DOCKERFILE="jre8/Dockerfile"
elif [[ "$TAG" == v11* ]]; then
IMAGE_TAG="jre11"
DOCKERFILE="jre11/Dockerfile"
elif [[ "$TAG" == v17* ]]; then
IMAGE_TAG="jre17"
DOCKERFILE="jre17/Dockerfile"
elif [[ "$TAG" == v21* ]]; then
IMAGE_TAG="jre21"
DOCKERFILE="jre21/Dockerfile"
elif [[ "$TAG" == v23* ]]; then
IMAGE_TAG="jre23"
DOCKERFILE="jre23/Dockerfile"
else
# 如果标签不符合预期,输出错误并退出
echo "不支持的标签版本: $TAG"
exit 1
fi
# 只构建一次并同时标记版本标签和 latest 标签
docker build -f $DOCKERFILE . --tag ${{ secrets.DOCKER_USERNAME }}/$IMAGE_TAG:$TAG --tag ${{ secrets.DOCKER_USERNAME }}/$IMAGE_TAG:latest
# 推送构建好的镜像,推送两个标签:版本标签和 latest 标签
docker push ${{ secrets.DOCKER_USERNAME }}/$IMAGE_TAG:$TAG
docker push ${{ secrets.DOCKER_USERNAME }}/$IMAGE_TAG:latest
env:
DOCKER_CLI_EXPERIMENTAL: enabled
DOCKER_BUILDKIT: 1
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}