-
Notifications
You must be signed in to change notification settings - Fork 15
131 lines (114 loc) · 4.81 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
name: build
on:
workflow_dispatch:
inputs:
odoo_target:
description: "Odoo Version"
required: true
type: choice
options:
- "18.0"
default: "18.0"
repository_dispatch:
types:
- webhook
concurrency:
# Gruop by Odoo Version
group: ${{ github.event.inputs.odoo_target || github.event.client_payload.odoo_target }}
cancel-in-progress: true
jobs:
geoip:
name: GeoIp
runs-on: ubuntu-latest
env:
MAXMIND_LICENSE_USR: ${{ secrets.MAXMIND_LICENSE_USR }}
MAXMIND_LICENSE_KEY: ${{ secrets.MAXMIND_LICENSE_KEY }}
outputs:
last-modified: ${{ steps.get-last-modified.outputs.last-modified }}
steps:
- name: Check if GeoIP has any update
id: get-last-modified
run: |
MAXMIND_UPDATE=$(curl -I -sL -u ${MAXMIND_LICENSE_USR}:${MAXMIND_LICENSE_KEY} 'https://download.maxmind.com/geoip/databases/GeoLite2-City/download?suffix=tar.gz' | grep -i 'Last-Modified')
MAXMIND_UPDATE=${MAXMIND_UPDATE#*: }
MAXMIND_UPDATE=$(date -d "$MAXMIND_UPDATE" +"%Y%m%d%H%M%S")
echo "last-modified=$MAXMIND_UPDATE" >> $GITHUB_OUTPUT
build:
name: Build
runs-on: ubuntu-latest
needs:
- geoip
env:
ODOO_TARGET: ${{ github.event.inputs.odoo_target || github.event.client_payload.odoo_target }}
ODOO_BUILD: 0
ODOO_BY_ADHOC_BUILD: 0
MAXMIND_GEOIP_UPDATE: ${{ needs.geoip.outputs.last-modified }}
# MAXMIND_LICENSE_USR: ${{ secrets.MAXMIND_LICENSE_USR }}
# MAXMIND_LICENSE_KEY: ${{ secrets.MAXMIND_LICENSE_KEY }}
# GITHUB_BOT_TOKEN: ${{ secrets.BOT_TOKEN_GITHUB }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Get odoo build
id: get-odoo-build
run: echo "date=$(/bin/date -u "+%Y%m")" >> $GITHUB_OUTPUT
- name: Get odoo build
id: get-odoo-adhoc-build
run: echo "date=$(/bin/date -u "+%Y.%m.%d")" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Login to Docker Hub (for pushing the final image)
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
registry: docker.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Build lower layers
# TODO: Upload odoo version.
- name: Build dev
uses: docker/build-push-action@v6
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: .
push: true
build-args: |
MAXMIND_LICENSE_USER=${{ secrets.MAXMIND_LICENSE_USR }}
MAXMIND_LICENSE_KEY=${{ secrets.MAXMIND_LICENSE_KEY }}
MAXMIND_UPDATE=${{ env.MAXMIND_UPDATE }}
ODOO_VERSION=${{ env.ODOO_TARGET }}
ODOO_BUILD=${{ steps.get-odoo-build.outputs.date }}
SAAS_PROVIDER_URL=${{ secrets.SAAS_PROVIDER_URL }}
SAAS_PROVIDER_TOKEN=${{ secrets.SAAS_PROVIDER_TOKEN }}
GITHUB_BOT_TOKEN=${{ secrets.BOT_TOKEN_GITHUB }}
ODOO_BY_ADHOC_BUILD=${{ steps.get-odoo-adhoc-build.outputs.date }}.${{ github.run_number }}
# Force to recreate this layer (this is no longer needed due the ODOO_BY_ADHOC_BUILD)
# no-cache-filters: aggregate-source
target: dev
tags: |
docker.io/adhoc/odoo-adhoc:${{ env.ODOO_TARGET }}.next.${{ steps.get-odoo-adhoc-build.outputs.date }}.${{ github.run_number }}.dev
docker.io/adhoc/odoo-adhoc:${{ env.ODOO_TARGET }}.next.${{ steps.get-odoo-adhoc-build.outputs.date }}.dev
docker.io/adhoc/odoo-adhoc:${{ env.ODOO_TARGET }}.next.dev
- name: Build prod
uses: docker/build-push-action@v6
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: .
push: true
build-args: |
MAXMIND_LICENSE_USER=${{ secrets.MAXMIND_LICENSE_USR }}
MAXMIND_LICENSE_KEY=${{ secrets.MAXMIND_LICENSE_KEY }}
MAXMIND_UPDATE=${{ env.MAXMIND_UPDATE }}
ODOO_VERSION=${{ env.ODOO_TARGET }}
ODOO_BUILD=${{ steps.get-odoo-build.outputs.date }}
SAAS_PROVIDER_URL=${{ secrets.SAAS_PROVIDER_URL }}
SAAS_PROVIDER_TOKEN=${{ secrets.SAAS_PROVIDER_TOKEN }}
GITHUB_BOT_TOKEN=${{ secrets.BOT_TOKEN_GITHUB }}
ODOO_BY_ADHOC_BUILD=${{ steps.get-odoo-adhoc-build.outputs.date }}.${{ github.run_number }}
target: prod
tags: |
docker.io/adhoc/odoo-adhoc:${{ env.ODOO_TARGET }}.next.${{ steps.get-odoo-adhoc-build.outputs.date }}.${{ github.run_number }}
docker.io/adhoc/odoo-adhoc:${{ env.ODOO_TARGET }}.next.${{ steps.get-odoo-adhoc-build.outputs.date }}
docker.io/adhoc/odoo-adhoc:${{ env.ODOO_TARGET }}.next