forked from odoo/odoo
-
Notifications
You must be signed in to change notification settings - Fork 0
160 lines (143 loc) · 4.72 KB
/
build.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
name: Build Docker Image
on:
push:
branches:
- 'jobrad-**'
tags:
- 'jobrad-**'
jobs:
build-docker-amd64:
runs-on: self-hosted
permissions:
contents: read
packages: write
env:
GHCR_IMAGE_NAME: ghcr.io/jobrad-gmbh/odoo
steps:
- uses: actions/checkout@v3
- 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:
- uses: actions/checkout@v3
- 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
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
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}"
# TODO Push to artifactory
test:
runs-on: self-hosted
needs: combine-docker
steps:
- name: Run base Odoo tests
uses: cloudposse/github-action-docker-compose-test-run@main
with:
file: tests/docker-compose.yml
service: odoo
entrypoint: sh -c
command: ./odoo-bin -d test --test-enable --stop