Files
reusing_workflows/.github/workflows/publish_docker.yml
2024-03-08 10:18:22 +08:00

87 lines
2.4 KiB
YAML

name: publish
on:
workflow_call:
inputs:
artifact-skip:
required: false
type: boolean
default: false
artifact-name:
required: false
type: string
default: 'artifact'
docker_context:
required: false
type: string
default: '.'
dockerfile_path:
required: false
type: string
default: './Dockerfile'
http_proxy:
required: false
type: string
default: 'http://192.168.0.20:7890'
jobs:
publish-docker-image:
runs-on: ubuntu_act_on_20
# container:
# image: catthehacker/ubuntu:act-latest
env:
RUNNER_TOOL_CACHE: /toolcache
steps:
- uses: actions/download-artifact@v3
if: ${{ inputs.artifact-skip != true }}
with:
name: ${{ inputs.artifact-name }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker BuildX
uses: docker/setup-buildx-action@v2
with:
driver-opts: |
network=act_runner_default
env.http_proxy=http://act_clash:7890
env.https_proxy=http://act_clash:7890
- name: Login to Docker Registry
uses: docker/login-action@v2
with:
registry: ${{ secrets.REGISTRY_HOST }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: | # my-docker-hub-namespace/my-docker-hub-repository
${{ secrets.REGISTRY_HOST }}/${{ github.repository }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern=v{{major}}
- name: Build and push
uses: docker/build-push-action@v4
with:
network: host
build-args: |
http_proxy=${{ inputs.http_proxy }}
https_proxy=${{ inputs.http_proxy }}
version=${{ steps.meta.outputs.version }}
context: ${{ inputs.docker_context }}
file: ${{ inputs.dockerfile_path }}
platforms: |
linux/amd64
linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}