56 lines
1.6 KiB
YAML
56 lines
1.6 KiB
YAML
on:
|
|
workflow_call:
|
|
inputs:
|
|
working_dir:
|
|
required: false
|
|
type: string
|
|
default: '.'
|
|
image_name:
|
|
required: true
|
|
type: string
|
|
registry:
|
|
required: false
|
|
type: string
|
|
default: 'git.moujtahid.com'
|
|
secrets:
|
|
REGISTRY_USER:
|
|
required: true
|
|
REGISTRY_PASSWORD:
|
|
required: true
|
|
|
|
env:
|
|
REGISTRY: git.moujtahid.com
|
|
DOCKER_HOST: tcp://localhost:2375
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
DOCKER_HOST: tcp://localhost:2375
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
with:
|
|
driver: docker
|
|
driver-opts: |
|
|
image=moby/buildkit:latest
|
|
|
|
- name: Login to Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ inputs.registry }}
|
|
username: ${{ gitea.actor }}
|
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
|
|
- name: Build and Push
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: ${{ inputs.working_dir }}
|
|
push: true
|
|
tags: |
|
|
${{ inputs.registry }}/${{ gitea.repository }}/${{ inputs.image_name }}:latest
|
|
${{ inputs.registry }}/${{ gitea.repository }}/${{ inputs.image_name }}:${{ gitea.sha }}
|
|
cache-from: type=registry,ref=${{ inputs.registry }}/${{ gitea.repository }}/${{ inputs.image_name }}:cache
|
|
cache-to: type=registry,ref=${{ inputs.registry }}/${{ gitea.repository }}/${{ inputs.image_name }}:cache,mode=max |