name: 'build docker image and push to registry (default: code)' inputs: registry: description: 'Docker registry URL' required: true default: '${{ vars.DOCKER_REGISTRY }}' # 使用原 vars 值作为默认值 user: description: 'Docker registry username' required: true default: '${{ vars.DOCKER_USER }}' # 使用原 vars 值作为默认值 pass: description: 'Docker registry password' required: true default: '${{ vars.DOCKER_PASS }}' # 使用原 vars 值作为默认值 image: description: 'Docker image name' required: true default: '${{ github.repository }}' # 使用 GitHub 仓库名称作为默认值 tag: description: 'Docker image tag (default: main)' required: false default: '${{ github.ref_name }}' # 使用 GitHub 分支名称作为默认值 platform: description: 'Build platform (default: linux/amd64)' required: false default: 'linux/amd64' # 默认构建平台为 x86 dockerfile: description: 'Path to the Dockerfile (default: Dockerfile)' required: false default: 'Dockerfile' # 默认 Dockerfile 名称 runs: using: 'composite' steps: - name: build docker image uses: docker://docker:git with: entrypoint: "/bin/sh" args: | -c 'docker ps && docker info && docker build --platform ${{ inputs.platform }} \ -t ${{ inputs.registry }}/${{ inputs.image }}:${{ inputs.tag }} -f ${{ inputs.dockerfile }} . && \ echo ${{ inputs.registry }}/${{ inputs.image }}:${{ inputs.tag }} 已经构建完了 && \ docker login ${{ inputs.registry }} -u ${{ inputs.user }} -p ${{ inputs.pass }} && \ docker push ${{ inputs.registry }}/${{ inputs.image }}:${{ inputs.tag }} && \ echo ${{ inputs.registry }}/${{ inputs.image }}:${{ inputs.tag }} 推送成功'