98 lines
3.7 KiB
YAML
98 lines
3.7 KiB
YAML
|
name: Build Docker Images
|
||
|
on:
|
||
|
workflow_dispatch:
|
||
|
inputs:
|
||
|
tag:
|
||
|
description: "The tag version or branch you want to build"
|
||
|
required: true
|
||
|
default: "main"
|
||
|
buildType:
|
||
|
description: "The type of build you want to build"
|
||
|
required: true
|
||
|
default: 'standard'
|
||
|
type: choice
|
||
|
options:
|
||
|
- standard
|
||
|
- minimized
|
||
|
- full
|
||
|
distro:
|
||
|
description: "The distro you want to build"
|
||
|
required: true
|
||
|
default: 'alpine'
|
||
|
type: choice
|
||
|
options:
|
||
|
- alpine
|
||
|
- distroless
|
||
|
|
||
|
jobs:
|
||
|
build:
|
||
|
runs-on: ubuntu-latest
|
||
|
steps:
|
||
|
- name: Checkout Action Repo
|
||
|
uses: actions/checkout@v3
|
||
|
with:
|
||
|
path: action
|
||
|
- name: Checkout Source Code of 'SagerNet/sing-box'
|
||
|
uses: actions/checkout@v3
|
||
|
with:
|
||
|
repository: 'SagerNet/sing-box'
|
||
|
ref: ${{ github.event.inputs.branch }}
|
||
|
submodules: true
|
||
|
- name: Setup Docker Buildx
|
||
|
uses: docker/setup-buildx-action@v2
|
||
|
- name: Setup QEMU for Docker Buildx
|
||
|
uses: docker/setup-qemu-action@v2
|
||
|
- name: Select Dockerfile
|
||
|
run: |
|
||
|
if [[ "${{ github.event.inputs.buildType }}" == "full" ]]; then
|
||
|
if [[ "${{ github.event.inputs.distro }}" == "distroless" ]]; then
|
||
|
cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.distroless.full" > Dockerfile
|
||
|
echo "tag_postfix=-full-distroless" >> $GITHUB_OUTPUT
|
||
|
else
|
||
|
cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.full" > Dockerfile
|
||
|
echo "tag_postfix=-full" >> $GITHUB_OUTPUT
|
||
|
if [[ "${{ github.event.inputs.distro }}" == "distroless" ]]; then
|
||
|
fi
|
||
|
elif [[ "${{ github.event.inputs.buildType }}" == "minimized" ]]; then
|
||
|
if [[ "${{ github.event.inputs.distro }}" == "distroless" ]]; then
|
||
|
cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.distroless.minimized" > Dockerfile
|
||
|
echo "tag_postfix=-mini-distroless" >> $GITHUB_OUTPUT
|
||
|
else
|
||
|
cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.minimized" > Dockerfile
|
||
|
echo "tag_postfix=-mini" >> $GITHUB_OUTPUT
|
||
|
fi
|
||
|
else
|
||
|
if [[ "${{ github.event.inputs.distro }}" == "distroless" ]]; then
|
||
|
cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.distroless.standard" > Dockerfile
|
||
|
else
|
||
|
cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.standard" > Dockerfile
|
||
|
fi
|
||
|
fi
|
||
|
- name: Login to Docker Hub Container Registry
|
||
|
uses: docker/login-action@v2
|
||
|
with:
|
||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||
|
- name: Docker metadata
|
||
|
id: metadata
|
||
|
uses: docker/metadata-action@v4
|
||
|
with:
|
||
|
images: etnperlong/sing-box
|
||
|
- name: Get tag to build
|
||
|
id: tag
|
||
|
run: |
|
||
|
echo "latest=etnperlong/sing-box:latest" >> $GITHUB_OUTPUT
|
||
|
if [[ -z "${{ github.event.inputs.tag }}" ]]; then
|
||
|
echo "versioned=etnperlong/sing-box:${{ github.ref_name }}" >> $GITHUB_OUTPUT
|
||
|
else
|
||
|
echo "versioned=etnperlong/sing-box:${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
|
||
|
fi
|
||
|
- name: Build and release Docker images
|
||
|
uses: docker/build-push-action@v4
|
||
|
with:
|
||
|
platforms: linux/386,linux/amd64,linux/arm64,linux/arm/v7,linux/s390x
|
||
|
target: dist
|
||
|
tags: |
|
||
|
${{ steps.tag.outputs.latest }}
|
||
|
${{ steps.tag.outputs.versioned }}
|
||
|
push: true
|