actions/docker/action.yaml

46 lines
1.2 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
image:
required: true
type: string
tag:
required: false
type: string
secrets:
registry_user:
required: true
type: string
registry_pass:
required: true
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
- name: Install docker
2023-07-28 12:22:23 -04:00
run: |
apt update && apt install curl -y
curl -fsSL https://get.docker.com | sh
2023-07-28 12:15:20 -04:00
2023-07-28 10:44:12 -04:00
- name: Login to registry
run: |
REGISTRY=$([ -n "${{inputs.registry}}" ] && echo "${{inputs.registry}}" || echo "$GITHUB_SERVER_URL")
echo "${{secrets.registry_pass}}" | docker login -u "${{secrets.registry_user}}" --password-stdin "$REGISTRY"
2023-07-28 10:27:37 -04:00
2023-07-28 10:44:12 -04:00
- uses: actions/checkout@v3
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"