-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (127 loc) · 5.02 KB
/
Copy pathcd.yml
File metadata and controls
142 lines (127 loc) · 5.02 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: CD
on:
push:
tags:
- 'v*'
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_PREFIX: ${{ github.repository_owner }}/tjudge
jobs:
build-and-push:
name: Build and Push Images
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
outputs:
api_image: ${{ steps.meta-api.outputs.tags }}
worker_image: ${{ steps.meta-worker.outputs.tags }}
executor_image: ${{ steps.meta-executor.outputs.tags }}
steps:
- uses: actions/checkout@v5
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# API Image
- name: Extract metadata for API
id: meta-api
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}-api
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
# `latest` для финальных релизов (без alpha/beta/rc) — так prod
# compose без VERSION-env подтягивает свежий релиз.
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, 'alpha') && !contains(github.ref, 'beta') && !contains(github.ref, 'rc') }}
- name: Build and push API image
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/api/Dockerfile
push: true
tags: ${{ steps.meta-api.outputs.tags }}
labels: ${{ steps.meta-api.outputs.labels }}
# Тег релиза (или ветка/sha) — отображается в /system/status и доктор-отчётах.
build-args: |
VERSION=${{ github.ref_name }}
cache-from: type=gha
cache-to: type=gha,mode=max
# Worker Image
- name: Extract metadata for Worker
id: meta-worker
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}-worker
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, 'alpha') && !contains(github.ref, 'beta') && !contains(github.ref, 'rc') }}
- name: Build and push Worker image
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/worker/Dockerfile
push: true
tags: ${{ steps.meta-worker.outputs.tags }}
labels: ${{ steps.meta-worker.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
# Executor Image (tjudge-cli)
- name: Extract metadata for Executor
id: meta-executor
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}-executor
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, 'alpha') && !contains(github.ref, 'beta') && !contains(github.ref, 'rc') }}
- name: Build and push Executor image
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/tjudge/Dockerfile
push: true
tags: ${{ steps.meta-executor.outputs.tags }}
labels: ${{ steps.meta-executor.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
# Builder Image (tjudge-builder): песочница компиляции программ
- name: Extract metadata for Builder
id: meta-builder
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}-builder
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, 'alpha') && !contains(github.ref, 'beta') && !contains(github.ref, 'rc') }}
- name: Build and push Builder image
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/builder/Dockerfile
push: true
tags: ${{ steps.meta-builder.outputs.tags }}
labels: ${{ steps.meta-builder.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max