Skip to content

Build and push LAYA SERVER #2

Build and push LAYA SERVER

Build and push LAYA SERVER #2

name: Build and push LAYA SERVER
on:
workflow_dispatch:
inputs:
dockerImageTag:
description: "Docker Hub tag (for example v0.1.0 or dev)"
required: true
default: dev
type: string
dockerImageTagWithLatest:
description: "Also publish latest"
required: true
default: false
type: boolean
runner:
description: "GitHub runner"
required: true
default: ubuntu-latest
type: choice
options:
- ubuntu-latest
- self-hosted
permissions:
contents: read
concurrency:
group: laya-server-build-and-push
cancel-in-progress: false
jobs:
build-and-push-to-dockerhub:
runs-on: ${{ inputs.runner }}
steps:
- name: Check out LAYA SERVER
uses: actions/checkout@v6
- name: Validate image tag
id: image
shell: bash
env:
IMAGE_TAG: ${{ inputs.dockerImageTag }}
WITH_LATEST: ${{ inputs.dockerImageTagWithLatest }}
run: |
if [[ ! "$IMAGE_TAG" =~ ^[A-Za-z0-9_][A-Za-z0-9_.-]{0,127}$ ]]; then
echo 'Invalid Docker image tag' >&2
exit 1
fi
echo "tag=$IMAGE_TAG" >> "$GITHUB_OUTPUT"
echo "with_latest=$WITH_LATEST" >> "$GITHUB_OUTPUT"
- name: Check out pinned upstream Laya
shell: bash
run: |
git clone --depth 1 --branch v0.3.7 https://github.com/NandhaKishorM/laya.git laya
git -C laya checkout --detach 010bacef009c855ccba814b51f7c8e1d38ab5e3f
sh scripts/check-upstream.sh
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Test API contracts
run: |
python -m pip install -e 'backend[test]'
python -m pytest backend/tests -q
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push 1panel/laya-server
shell: bash
env:
IMAGE_TAG: ${{ steps.image.outputs.tag }}
WITH_LATEST: ${{ steps.image.outputs.with_latest }}
run: |
tags=(--tag "1panel/laya-server:$IMAGE_TAG")
if [[ "$WITH_LATEST" == 'true' && "$IMAGE_TAG" != 'latest' ]]; then
tags+=(--tag '1panel/laya-server:latest')
fi
docker buildx build \
--platform linux/amd64 \
--output type=image,push=true \
"${tags[@]}" \
.