mirror of https://github.com/zcash/.github.git
77 lines
2.1 KiB
YAML
77 lines
2.1 KiB
YAML
name: Build and Push Docker Image to Docker Hub
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
image_name:
|
|
description: "Name of the Docker image to build and push"
|
|
required: true
|
|
type: string
|
|
image_tags:
|
|
description: "Comma-separated list of tags for the Docker image"
|
|
required: true
|
|
type: string
|
|
dockerfile:
|
|
description: "Path to the Dockerfile"
|
|
required: true
|
|
type: string
|
|
context:
|
|
description: "Build context for the Docker image"
|
|
required: true
|
|
type: string
|
|
build-args:
|
|
description: "Docker build args"
|
|
required: true
|
|
type: string
|
|
secrets:
|
|
dockerhub_registry:
|
|
required: true
|
|
description: "Docker Hub registry URL (e.g., docker.io)"
|
|
dockerhub_username:
|
|
required: true
|
|
description: "Docker Hub username"
|
|
dockerhub_password:
|
|
required: true
|
|
description: "Docker Hub password"
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Set Docker Image Tags
|
|
id: set-tags
|
|
run: |
|
|
TAGS="${{ inputs.image_tags }}"
|
|
REGISTRY="${{ secrets.dockerhub_registry }}/${{ inputs.image_name }}"
|
|
IFS=',' read -ra ELEMENTS <<< "$TAGS"
|
|
TAGS_FIXED=""
|
|
for ELEMENT in "${ELEMENTS[@]}"; do
|
|
TAGS_FIXED+="$REGISTRY:$ELEMENT,"
|
|
done
|
|
TAGS_FIXED=${TAGS_FIXED%,}
|
|
echo "tags_fixed=$TAGS_FIXED" >> $GITHUB_ENV
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.dockerhub_username }}
|
|
password: ${{ secrets.dockerhub_password }}
|
|
|
|
- name: Build and Push
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
file: ${{ inputs.dockerfile }}
|
|
context: ${{ inputs.context }}
|
|
push: true
|
|
tags: ${{ env.tags_fixed }}
|
|
build-args: ${{ inputs.build-args }}
|