54 lines
1.1 KiB
YAML
54 lines
1.1 KiB
YAML
name: Reusable Docker Build
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
dockerfile:
|
|
required: true
|
|
type: string
|
|
|
|
image_name:
|
|
required: true
|
|
type: string
|
|
|
|
secrets:
|
|
REGISTRY_USER:
|
|
required: true
|
|
|
|
REGISTRY_PASSWORD:
|
|
required: true
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: docker-build
|
|
|
|
outputs:
|
|
image_ref: ${{ steps.vars.outputs.image_ref }}
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Prepare vars
|
|
id: vars
|
|
run: |
|
|
REGISTRY="gitea.rellet.ir"
|
|
TAG="${GITHUB_SHA:0:7}"
|
|
|
|
IMAGE_REF="$REGISTRY/${{ inputs.image_name }}:$TAG"
|
|
|
|
echo "image_ref=$IMAGE_REF" >> $GITHUB_OUTPUT
|
|
|
|
- name: Login
|
|
run: |
|
|
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login gitea.rellet.ir \
|
|
-u "${{ secrets.REGISTRY_USER }}" \
|
|
--password-stdin
|
|
|
|
- name: Build and Push
|
|
run: |
|
|
docker buildx build \
|
|
-f ${{ inputs.dockerfile }} \
|
|
-t ${{ steps.vars.outputs.image_ref }} \
|
|
--push \
|
|
. |