Skip to content

Commit b850377

Browse files
committed
upd: workflow
1 parent 59d9ba1 commit b850377

2 files changed

Lines changed: 55 additions & 94 deletions

File tree

.github/workflows/docker_auto.yml

Lines changed: 54 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,112 +1,73 @@
1-
name: Automatic build on release and push to Docker Hub
1+
name: Build & Publish Odoo Images (multi-version)
2+
23
on:
34
schedule:
45
- cron: "0 0 * * SUN"
56
push:
67
branches:
78
- master
9+
workflow_dispatch:
10+
11+
env:
12+
REGISTRY: ghcr.io
13+
IMAGE_NAME: ${{ github.repository }}
14+
LATEST_VERSION: "19.0"
15+
816
jobs:
9-
tests:
10-
uses: ./.github/workflows/test.yml
11-
publish-docker-image:
17+
build-and-push:
1218
runs-on: ubuntu-latest
13-
needs:
14-
- tests
15-
env:
16-
DOCKER_PLATFORMS: linux/amd64,linux/arm64
17-
DOCKER_IMAGE: ghtardo/docker-privoxy-https
18-
LASTEST_VERSION: "4.0.0"
19-
PRIVOXY_VERSION: "4.0.0"
20-
steps:
21-
- name: Set up QEMU
22-
uses: docker/setup-qemu-action@v3
23-
24-
- name: Set up Docker Buildx
25-
id: buildx
26-
uses: docker/setup-buildx-action@v3
19+
needs: pytest
20+
permissions:
21+
contents: read
22+
packages: write
23+
attestations: write
24+
id-token: write
2725

28-
- name: Login to Docker Hub
29-
id: login
30-
uses: docker/login-action@v3
31-
with:
32-
username: ${{ secrets.DOCKER_HUB_USERNAME }}
33-
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
26+
strategy:
27+
matrix:
28+
version: ["6.0", "6.1", "7.0", "8.0", "9.0", "10.0", "11.0", "12.0", "13.0", "14.0", "15.0", "16.0", "17.0", "18.0", "19.0"]
3429

35-
- name: Cache Docker layers
36-
uses: actions/cache@v4
37-
with:
38-
path: /tmp/.buildx-cache
39-
key: ${{ runner.os }}-buildx-${{ github.sha }}
40-
restore-keys: |
41-
${{ runner.os }}-buildx-
42-
- name: Check out repo
43-
id: checkout
44-
uses: actions/checkout@v4
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v6
4533

46-
- name: Prepare env variables
47-
id: env
48-
run: |
49-
echo "BUILD_BRANCH=$(echo $GITHUB_REF | cut -d / -f 3 | cut -d. -f-2 | cut -d- -f1)" >> $GITHUB_ENV
50-
echo "BUILD_VER=$(echo $GITHUB_REF | cut -d / -f 3)" >> $GITHUB_ENV
51-
echo "BUILD_DATE=$(date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_ENV
52-
echo "GIT_SHA=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_ENV
53-
echo "GIT_REF=$(git symbolic-ref -q --short HEAD || git describe --tags --exact-match)" >> $GITHUB_ENV
54-
- name: Build and push latest stable branch
55-
if: ${{ env.BUILD_VER == env.LASTEST_VERSION }}
56-
id: docker_build_latest
57-
uses: docker/build-push-action@v5
34+
- name: Docker meta
35+
id: meta
36+
uses: docker/metadata-action@v5
5837
with:
59-
context: .
60-
file: ./Dockerfile
61-
builder: ${{ steps.buildx.outputs.name }}
62-
platforms: ${{ env.DOCKER_PLATFORMS }}
63-
build-args: |
64-
PRIVOXY_VERSION=${{ env.PRIVOXY_VERSION }}
65-
push: true
66-
target: runtime
38+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
39+
tags: |
40+
type=raw,value=${{ matrix.version }}
41+
type=raw,value=latest,enable=${{ matrix.version == env.LATEST_VERSION }}
6742
labels: |
68-
org.opencontainers.image.authors=${{ github.repository_owner }}
69-
org.opencontainers.image.created=${{ env.BUILD_DATE }}
70-
org.opencontainers.image.description=Created from commit ${{ env.GIT_SHA }} and ref ${{ env.GIT_REF }}
71-
org.opencontainers.image.ref.name=${{ env.GIT_REF }}
72-
org.opencontainers.image.revision=${{ github.sha }}
43+
org.opencontainers.image.title=Odoo ${{ matrix.version }}
44+
org.opencontainers.image.description=Odoo Community ${{ matrix.version }} - isOdoo Image
7345
org.opencontainers.image.source=https://github.com/${{ github.repository }}
74-
org.opencontainers.image.version=${{ env.BUILD_VER }}
75-
tags: |
76-
${{ env.DOCKER_IMAGE }}:latest
77-
${{ env.DOCKER_IMAGE }}:${{ env.BUILD_BRANCH }}
78-
${{ env.DOCKER_IMAGE }}:${{ env.BUILD_VER }}
79-
cache-from: type=local,src=/tmp/.buildx-cache
80-
cache-to: type=local,dest=/tmp/.buildx-cache-new
46+
org.opencontainers.image.vendor=GrupoIsonor
47+
odoo.version=${{ matrix.version }}
48+
49+
- name: Login to GHCR
50+
uses: docker/login-action@v3
51+
with:
52+
registry: ${{ env.REGISTRY }}
53+
username: ${{ github.actor }}
54+
password: ${{ secrets.GITHUB_TOKEN }}
8155

82-
- name: Build and push everything else
83-
if: ${{ env.BUILD_VER != env.LASTEST_VERSION }}
84-
id: docker_build_regular
85-
uses: docker/build-push-action@v5
56+
- name: Build & Push
57+
id: build-and-push
58+
uses: docker/build-push-action@v6
8659
with:
8760
context: .
88-
file: ./Dockerfile
89-
builder: ${{ steps.buildx.outputs.name }}
90-
platforms: ${{ env.DOCKER_PLATFORMS }}
91-
build-args: |
92-
PRIVOXY_VERSION=${{ env.PRIVOXY_VERSION }}
61+
file: ./${{ matrix.version }}.Dockerfile
9362
push: true
94-
target: runtime
95-
labels: |
96-
org.opencontainers.image.authors=${{ github.repository_owner }}
97-
org.opencontainers.image.created=${{ env.BUILD_DATE }}
98-
org.opencontainers.image.description=Created from commit ${{ env.GIT_SHA }} and ref ${{ env.GIT_REF }}
99-
org.opencontainers.image.ref.name=${{ env.GIT_REF }}
100-
org.opencontainers.image.revision=${{ github.sha }}
101-
org.opencontainers.image.source=https://github.com/${{ github.repository }}
102-
org.opencontainers.image.version=${{ env.BUILD_VER }}
103-
tags: |
104-
${{ env.DOCKER_IMAGE }}:${{ env.BUILD_BRANCH }}
105-
${{ env.DOCKER_IMAGE }}:${{ env.BUILD_VER }}
106-
cache-from: type=local,src=/tmp/.buildx-cache
107-
cache-to: type=local,dest=/tmp/.buildx-cache-new
63+
tags: ${{ steps.meta.outputs.tags }}
64+
labels: ${{ steps.meta.outputs.labels }}
65+
cache-from: type=gha
66+
cache-to: type=gha,mode=max
10867

109-
- name: Move cache
110-
run: |
111-
rm -rf /tmp/.buildx-cache
112-
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
68+
- name: Attest build provenance
69+
uses: actions/attest-build-provenance@v2
70+
with:
71+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
72+
subject-digest: ${{ steps.build-and-push.outputs.digest }}
73+
push-to-registry: true

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
poetry install
4040
- uses: pre-commit/action@v3.0.1
4141

42-
isodoo:
42+
pytest:
4343
strategy:
4444
matrix:
4545
odoo_version:

0 commit comments

Comments
 (0)