Skip to content

Publish Image

Publish Image #408

Workflow file for this run

name: Publish Image
on:
workflow_dispatch:
inputs:
repo:
description: 'Lila repository to build'
required: false
default: 'lichess-org/lila'
type: string
branch:
description: 'Branch to build'
required: false
default: 'master'
type: string
platforms:
description: 'Target platforms for the build'
required: false
default: 'all'
type: choice
options:
- 'all'
- 'linux/amd64'
- 'linux/arm64'
schedule:
- cron: '0 17 * * *'
push:
paths:
- '.github/workflows/publish-image.yml'
- 'conf/mono.Caddyfile'
- 'conf/mono.conf'
- 'docker/mono.Dockerfile'
jobs:
build-and-publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
outputs:
is_lila_main: ${{ steps.build_vars.outputs.is_lila_main }}
steps:
- name: Setup build variables
id: build_vars
run: |
echo "repo=${{ github.event.inputs.repo || 'lichess-org/lila' }}" >> $GITHUB_OUTPUT
echo "branch=${{ github.event.inputs.branch || 'master' }}" >> $GITHUB_OUTPUT
if [ "${{ github.event.inputs.platforms || 'all' }}" = "all" ]; then
echo "platforms=linux/amd64,linux/arm64" >> $GITHUB_OUTPUT
else
echo "platforms=${{ github.event.inputs.platforms }}" >> $GITHUB_OUTPUT
fi
echo "is_lila_main=$([ "${{ github.event.inputs.repo || 'lichess-org/lila' }}" = "lichess-org/lila" ] && [ "${{ github.event.inputs.branch || 'master' }}" = "master" ] && echo "true" || echo "false")" >> $GITHUB_OUTPUT
- name: Checkout repository
uses: actions/checkout@v5
- name: Checkout lila
uses: actions/checkout@v5
with:
repository: ${{ steps.build_vars.outputs.repo }}
ref: ${{ steps.build_vars.outputs.branch }}
path: 'repos/lila'
- name: Checkout lila-ws
uses: actions/checkout@v5
with:
repository: 'lichess-org/lila-ws'
path: 'repos/lila-ws'
- name: Checkout lila-db-seed
uses: actions/checkout@v5
with:
repository: 'lichess-org/lila-db-seed'
path: 'repos/lila-db-seed'
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
image: tonistiigi/binfmt:qemu-v7.0.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=raw,prefix=lila-,value=${{ steps.build_vars.outputs.branch }}
type=raw,value=main,enable=${{ steps.build_vars.outputs.is_lila_main }}
type=raw,value=latest,enable=${{ steps.build_vars.outputs.is_lila_main }}
- name: Free disk space on Ubuntu runner
uses: kfir4444/free-disk-space@main
with:
tool-cache: true
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
platforms: ${{ steps.build_vars.outputs.platforms }}
file: docker/mono.Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
deploy:
needs: build-and-publish
runs-on: ubuntu-latest
if: needs.build-and-publish.outputs.is_lila_main == 'true'
steps:
- name: Deploy nightly test site
run: curl --fail -X POST ${{ secrets.WEBHOOK_DEPLOY_NIGHTLY }}