71 lines
1.9 KiB
YAML
71 lines
1.9 KiB
YAML
name: Build Docker image
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
github-server-url:
|
|
description: 'GitHub Server URL'
|
|
required: false
|
|
type: string
|
|
default: 'https://github.com'
|
|
|
|
repo:
|
|
description: '仓库名称'
|
|
required: true
|
|
type: string
|
|
|
|
ref:
|
|
description: '分支名称'
|
|
required: true
|
|
type: string
|
|
|
|
image_name:
|
|
description: '镜像名称'
|
|
required: true
|
|
type: string
|
|
|
|
image_tag:
|
|
description: '镜像标签'
|
|
required: false
|
|
default: 'latest'
|
|
type: string
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
jobs:
|
|
publish-docker:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v5
|
|
with:
|
|
repository: ${{ github.event.inputs.repo }}
|
|
ref: ${{ github.event.inputs.ref }}
|
|
fetch-tags: true
|
|
github-server-url: ${{ github.event.inputs.github-server-url }}
|
|
|
|
- name: GET lowercase repository owner
|
|
id: lowercase
|
|
run: echo "owner=$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Login to GitHub Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ steps.lowercase.outputs.owner }}
|
|
password: ${{ github.token }}
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: ghcr.io/${{ steps.lowercase.outputs.owner }}/${{ github.event.inputs.image_name }}:${{ github.event.inputs.image_tag }}
|
|
platforms: linux/amd64, linux/arm64, linux/arm/v7 |