-
Notifications
You must be signed in to change notification settings - Fork 14
140 lines (125 loc) · 3.75 KB
/
ci.yml
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
name: Build and Push
on:
push:
branches:
- main
release:
types:
- published
pull_request:
types:
- opened
- reopened
workflow_dispatch:
permissions:
contents: read
id-token: write
jobs:
build:
uses: ./.github/workflows/base.yml
with:
job-type: build
lint:
uses: ./.github/workflows/base.yml
with:
job-type: lint
build-docker:
runs-on: ubuntu-latest
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
permissions:
contents: read
packages: write
services:
clickhouse:
image: ghcr.io/duyet/docker-images:clickhouse_24.6
ports:
- 8123:8123
- 9000:9000
options: >-
--health-cmd "wget --no-verbose --tries=1 --spider http://localhost:8123/?query=SELECT%201 || exit 1"
--health-interval 30s
--health-timeout 10s
--health-retries 5
--health-start-period 30s
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: |
network=host
- name: Log in to the Container registry
uses: docker/login-action@7ca345011ac4304463197fac0e56eab1bc7e6af0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@906ecf0fc0a80f9110f79d9e6c04b1080f4a2621
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,prefix=
type=schedule,pattern={{date 'YYYYMMDD'}}
- name: Build and push
uses: docker/build-push-action@v6
with:
push: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
allow: network.host,security.insecure
network: host
platforms: linux/amd64,linux/arm64
build-args: |
GITHUB_REF=$GITHUB_REF
GITHUB_SHA=$GITHUB_SHA
outputs:
tags: ${{ steps.meta.outputs.tags }}
first_tag: ${{ fromJSON(steps.meta.outputs.json).tags[0] }}
validate-docker-build:
runs-on: ubuntu-latest
needs: build-docker
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags') }}
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
permissions:
contents: read
packages: write
services:
clickhouse:
image: ghcr.io/duyet/docker-images:clickhouse_testing
ports:
- 8123:8123
- 9000:9000
options: >-
--health-cmd "wget --no-verbose --tries=1 --spider http://localhost:8123/?query=SELECT%201 || exit 1"
--health-interval 30s
--health-timeout 10s
--health-retries 5
--health-start-period 30s
test-image:
image: ${{ needs.build-docker.outputs.first_tag }}
env:
CLICKHOUSE_HOST: http://clickhouse:8123
CLICKHOST_USER: default
CLICKHOST_PASS: ''
ports:
- 3000:3000
steps:
- name: Test image
run: |
curl -sSf http://localhost:3000/healthz || exit 1
curl -sSf http://localhost:3000/api/version || exit 1