build-and-push #81
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build-and-push | |
on: | |
workflow_dispatch: | |
inputs: | |
dockerImageTag: | |
description: 'Docker Image Tag' | |
default: 'v1.0.0-dev' | |
required: true | |
architecture: | |
description: 'Architecture' | |
required: true | |
default: 'linux/amd64' | |
type: choice | |
options: | |
- linux/amd64 | |
- linux/arm64 | |
- linux/amd64,linux/arm64 | |
registry: | |
description: 'Push To Registry' | |
required: true | |
default: 'dockerhub' | |
type: choice | |
options: | |
- dockerhub | |
- fit2cloud-registry | |
- dockerhub, fit2cloud-registry | |
jobs: | |
build-and-push-to-fit2cloud-registry: | |
if: ${{ contains(github.event.inputs.registry, 'fit2cloud') }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check Disk Space | |
run: df -h | |
- name: Free Disk Space (Ubuntu) | |
uses: jlumbroso/free-disk-space@main | |
with: | |
tool-cache: true | |
android: true | |
dotnet: true | |
haskell: true | |
large-packages: true | |
docker-images: true | |
swap-storage: true | |
- name: Check Disk Space | |
run: df -h | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
- name: Prepare | |
id: prepare | |
run: | | |
DOCKER_IMAGE=registry-hkproxy.fit2cloud.com/maxkb/maxkb | |
DOCKER_PLATFORMS=${{ github.event.inputs.architecture }} | |
TAG_NAME=${{ github.event.inputs.dockerImageTag }} | |
if [[ ${TAG_NAME} == *dev* ]]; then | |
DOCKER_IMAGE_TAGS="--tag ${DOCKER_IMAGE}:${TAG_NAME}" | |
else | |
DOCKER_IMAGE_TAGS="--tag ${DOCKER_IMAGE}:${TAG_NAME} --tag ${DOCKER_IMAGE}:latest" | |
fi | |
echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} --no-cache \ | |
${DOCKER_IMAGE_TAGS} . | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GH_TOKEN }} | |
- name: Login to FIT2CLOUD Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: registry-hkproxy.fit2cloud.com | |
username: ${{ secrets.FIT2CLOUD_REGISTRY_USERNAME }} | |
password: ${{ secrets.FIT2CLOUD_REGISTRY_PASSWORD }} | |
- name: Docker Buildx (build-and-push) | |
run: | | |
docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }} -f installer/Dockerfile | |
build-and-push-to-dockerhub: | |
if: ${{ contains(github.event.inputs.registry, 'dockerhub') }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check Disk Space | |
run: df -h | |
- name: Free Disk Space (Ubuntu) | |
uses: jlumbroso/free-disk-space@main | |
with: | |
tool-cache: true | |
android: true | |
dotnet: true | |
haskell: true | |
large-packages: true | |
docker-images: true | |
swap-storage: true | |
- name: Check Disk Space | |
run: df -h | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
- name: Prepare | |
id: prepare | |
run: | | |
DOCKER_IMAGE=1panel/maxkb | |
DOCKER_PLATFORMS=${{ github.event.inputs.architecture }} | |
TAG_NAME=${{ github.event.inputs.dockerImageTag }} | |
if [[ ${TAG_NAME} == *dev* ]]; then | |
DOCKER_IMAGE_TAGS="--tag ${DOCKER_IMAGE}:${TAG_NAME}" | |
else | |
DOCKER_IMAGE_TAGS="--tag ${DOCKER_IMAGE}:${TAG_NAME} --tag ${DOCKER_IMAGE}:latest" | |
fi | |
echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} --no-cache \ | |
${DOCKER_IMAGE_TAGS} . | |
env | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GH_TOKEN }} | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Docker Buildx (build-and-push) | |
run: | | |
docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }} -f installer/Dockerfile |