actions/docker/action.yaml

41 lines
1.0 KiB
YAML
Raw Normal View History

2023-07-28 10:44:12 -04:00
name: Push docker image
description: Build the local docker file & push to the registry
2023-07-28 10:27:37 -04:00
2023-07-28 10:44:12 -04:00
inputs:
registry:
required: false
type: string
2023-07-28 12:48:28 -04:00
default: $GITHUB_SERVER_URL
2023-07-28 10:44:12 -04:00
registry_user:
2023-07-28 12:48:28 -04:00
required: false
2023-07-28 10:44:12 -04:00
type: string
2023-07-28 12:48:28 -04:00
default: $GITHUB_ACTOR
2023-07-28 10:44:12 -04:00
registry_pass:
required: true
type: string
2023-07-28 12:42:48 -04:00
image:
required: true
type: string
2023-07-28 12:48:28 -04:00
default: $GITHUB_REPOSITORY
2023-07-28 12:42:48 -04:00
tag:
required: false
type: string
2023-07-28 10:27:37 -04:00
2023-07-28 10:44:12 -04:00
runs:
using: composite
steps:
2023-07-28 12:15:20 -04:00
2023-07-28 12:49:30 -04:00
- uses: actions/checkout@v3
2023-07-28 10:44:12 -04:00
- name: Login to registry
2023-07-28 12:48:28 -04:00
run: echo "${{inputs.registry_pass}}" | docker login -u "${{inputs.registry_user}}" --password-stdin "${{inputs.registry}}"
2023-07-28 10:27:37 -04:00
2023-07-28 10:44:12 -04:00
- name: Create tag
run: TAG=$([ -n "${{inputs.tag}}" ] && echo "${{inputs.tag}}" || [ "$GITHUB_REF" == "refs/heads/develop" ] && echo "latest" || echo "$GITHUB_REF_NAME" | sed -E "s/[_/]/-/g")
2023-07-28 10:27:37 -04:00
2023-07-28 10:44:12 -04:00
- name: Build image
run: docker build --no-cache -t "${{inputs.image}}:$TAG" .
2023-07-28 10:27:37 -04:00
2023-07-28 10:44:12 -04:00
- name: Push image
run: docker push "${{inputs.image}}:$TAG"