forked from odoo/odoo
-
Notifications
You must be signed in to change notification settings - Fork 0
198 lines (176 loc) · 5.72 KB
/
main.yaml
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
name: Build Docker Image
on:
push:
branches:
- 'jobrad-**'
tags:
- 'jobrad-**'
pull_request:
branches:
- '**'
jobs:
build-docker-amd64:
runs-on: self-hosted
permissions:
contents: read
packages: write
env:
GHCR_IMAGE_NAME: ghcr.io/jobrad-gmbh/odoo
steps:
- name: Clone
uses: actions/checkout@v3
- name: Clone enterprise addons
uses: actions/checkout@v3
with:
repository: jobrad-gmbh/odoo-addons-enterprise
ref: 14.0.10
token: ${{ secrets.ODOO_REPO_TOKEN }}
path: addons_enterprise
fetch-depth: 1
- name: Create variables
shell: bash
run: |
echo "BRANCH_NAME=$(echo ${GITHUB_REF} | sed 's/refs\/heads\///' | sed 's/refs\/tags\///' | sed 's/\//_/g')" >> $GITHUB_ENV
echo "SHORT_REV=$(echo ${{ github.sha }})" >> $GITHUB_ENV
- name: Login to ghcr registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64
driver-opts: |
image=moby/buildkit:buildx-stable-1
network=host
- name: Build and push Docker image (AMD64)
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile
platforms: linux/amd64
push: true
tags: |
${{ env.GHCR_IMAGE_NAME }}:${{ env.SHORT_REV }}-amd64
cache-from: |
type=gha,scope=image-amd64
cache-to: |
type=gha,scope=image-amd64,mode=max
provenance: false
build-docker-arm64:
runs-on: Linux-ARM64-2C-8GB
permissions:
contents: read
packages: write
env:
GHCR_IMAGE_NAME: ghcr.io/jobrad-gmbh/odoo
steps:
- name: Clone
uses: actions/checkout@v3
- name: Clone enterprise addons
uses: actions/checkout@v3
with:
repository: jobrad-gmbh/odoo-addons-enterprise
ref: 14.0.10
token: ${{ secrets.ODOO_REPO_TOKEN }}
path: addons_enterprise
fetch-depth: 1
- name: Create variables
shell: bash
run: |
echo "BRANCH_NAME=$(echo ${GITHUB_REF} | sed 's/refs\/heads\///' | sed 's/refs\/tags\///' | sed 's/\//_/g')" >> $GITHUB_ENV
echo "SHORT_REV=$(echo ${{ github.sha }})" >> $GITHUB_ENV
- name: Login to ghcr registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/arm64
driver-opts: |
image=moby/buildkit:buildx-stable-1
network=host
- name: Build and push Docker image (ARM64)
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile
platforms: linux/arm64
push: true
tags: |
${{ env.GHCR_IMAGE_NAME }}:${{ env.SHORT_REV }}-arm64
cache-from: |
type=gha,scope=image-arm64
cache-to: |
type=gha,scope=image-arm64,mode=max
provenance: false
combine-docker:
runs-on: [self-hosted, short]
needs: [build-docker-amd64, build-docker-arm64]
permissions:
contents: read
packages: write
env:
GHCR_IMAGE_NAME: ghcr.io/jobrad-gmbh/odoo
outputs:
IMAGE_REV: ${{ steps.manifest.outputs.IMAGE_REV }}
steps:
- name: Create variables
shell: bash
run: |
echo "BRANCH_NAME=$(echo ${GITHUB_REF} | sed 's/refs\/heads\///' | sed 's/refs\/tags\///' | sed 's/\//_/g')" >> $GITHUB_ENV
echo "SHORT_REV=$(echo ${{ github.sha }})" >> $GITHUB_ENV
- name: Login to ghcr registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to artifactory registry
uses: docker/login-action@v2
with:
registry: artifactory.service.jobrad.org
username: github_runner
password: ${{ secrets.ARTIFACTORY_TOKEN }}
- name: Combine Docker images into a single multi-architecture image
id: manifest
shell: bash
run: |
IMAGE_AMD64="${GHCR_IMAGE_NAME}:${SHORT_REV}-amd64"
IMAGE_ARM64="${GHCR_IMAGE_NAME}:${SHORT_REV}-arm64"
IMAGE_BRANCH="${GHCR_IMAGE_NAME}:${BRANCH_NAME}"
IMAGE_REV="${GHCR_IMAGE_NAME}:${SHORT_REV}"
docker pull "${IMAGE_AMD64}"
docker pull "${IMAGE_ARM64}"
docker manifest rm "${IMAGE_BRANCH}" || true
docker manifest rm "${IMAGE_REV}" || true
docker manifest create "${IMAGE_BRANCH}" "${IMAGE_AMD64}" "${IMAGE_ARM64}"
docker manifest create "${IMAGE_REV}" "${IMAGE_AMD64}" "${IMAGE_ARM64}"
docker manifest push "${IMAGE_BRANCH}"
docker manifest push "${IMAGE_REV}"
echo "IMAGE_REV=${IMAGE_REV}" >> $GITHUB_OUTPUT
# TODO Push to artifactory
test:
runs-on: self-hosted
needs: combine-docker
steps:
- uses: actions/checkout@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Run base Odoo tests
run: |
export ODOO_IMAGE=${{ needs.combine-docker.outputs.IMAGE_REV }}
./tests/run_tests.sh tests/modules
- name: Cleanup
if: always()
run: |
docker compose -f tests/docker-compose.yml down -v