-
-
Notifications
You must be signed in to change notification settings - Fork 97
115 lines (103 loc) · 3.57 KB
/
publish-image.yml
File metadata and controls
115 lines (103 loc) · 3.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
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 }}