actions/docker/build/action.yaml

41 lines
1.1 KiB
YAML
Raw Normal View History

2023-11-23 22:13:26 -05:00
name: Docker Build
description: Build docker image
inputs:
2023-11-24 11:43:01 -05:00
dockerfile:
type: string
required: false
default: Dockerfile
2023-11-23 22:13:26 -05:00
registry:
type: string
required: false
default: ${{github.server_url}}
name:
type: string
required: false
default: ${{github.repository}}
tag:
type: string
required: false
default: ${{github.ref_name}}
runs:
using: composite
steps:
2023-11-23 22:25:21 -05:00
- name: Creat Image Tag
run: echo "URL=$(echo ${{github.server_url}} | sed s%http://%% | sed s%https://%% )" >> $GITHUB_ENV
shell: sh
2023-11-24 16:51:48 -05:00
2023-11-23 22:15:06 -05:00
- name: Docker Build
2023-11-23 22:13:26 -05:00
uses: docker://docker
with:
entrypoint: docker
2023-11-23 22:25:21 -05:00
args: build -t "${{env.URL}}/${{inputs.name}}:${{inputs.tag}}" -f ${{inputs.dockerfile}} .
2023-11-24 16:51:48 -05:00
- name: Tag as Latest
if: ${{inputs.tag}} != latest && ${{github.ref_name}} == (git symbolic-ref refs/remotes/origin/HEAD --short | cut -c 7)
2023-11-24 16:53:04 -05:00
uses: docker://docker
2023-11-24 16:51:48 -05:00
with:
entrypoint: docker
args: tag "${{env.URL}}/${{inputs.name}}:${{inputs.tag}}" "${{env.URL}}/${{inputs.name}}:latest"