16
16
- uses : actions/checkout@v2
17
17
- uses : actions/setup-python@v1
18
18
- name : Set PY
19
- run :
20
- echo "PY=$(python -c 'import hashlib,
21
- sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')"
22
- >> $GITHUB_ENV
19
+ run : |
20
+ echo "PY=$(python -c 'import hashlib,sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')" >> $GITHUB_ENV
23
21
- uses : actions/cache@v1
24
22
with :
25
23
path : ~/.cache/pre-commit
32
30
strategy :
33
31
fail-fast : false
34
32
matrix :
35
- # Test modern Odoo versions with latest Postgres version
36
33
pg_version :
37
34
- " 16"
38
35
- " 15"
@@ -45,29 +42,39 @@ jobs:
45
42
env :
46
43
# Indicates what's the equivalent to tecnativa/postgres-autoconf:latest image
47
44
LATEST_RELEASE : " 16-alpine"
48
- # Variables found by default in Docker Hub builder
49
45
DOCKER_REPO : tecnativa/postgres-autoconf
50
46
DOCKER_TAG : ${{ matrix.pg_version }}-alpine
51
47
GIT_SHA1 : ${{ github.sha }}
48
+ IS_PR : ${{ github.event_name == 'pull_request' }}
52
49
steps :
53
- # Prepare
54
50
- uses : actions/checkout@v2
55
51
- uses : actions/setup-python@v1
56
52
- run : pip install -r tests/ci-requirements.txt
53
+
57
54
# Build images
58
55
- run : ./hooks/build
59
56
# Test
60
57
- run : python -m unittest tests.test -v
58
+ - name : Set Docker Tag
59
+ run : |
60
+ if [ "${{ env.IS_PR }}" = "true" ]; then
61
+ echo "DOCKER_TAG=${{ matrix.pg_version }}-test-pr${{ github.event.number }}" >> $GITHUB_ENV
62
+ else
63
+ echo "DOCKER_TAG=${{ matrix.pg_version }}-alpine" >> $GITHUB_ENV
64
+ fi
65
+ - name : Tag Docker Image for PR
66
+ if : env.IS_PR
67
+ run : docker tag ${{ env.DOCKER_REPO }}:${{ matrix.pg_version }}-alpine ${{ env.DOCKER_REPO }}:${{ env.DOCKER_TAG }}
61
68
# Push
62
- - name : push to docker hub
63
- if : github.repository == 'Tecnativa/docker-postgres-autoconf' && github.ref == 'refs/heads/master'
69
+ - name : Push Docker Image to Docker Hub
70
+ if : github.repository == 'Tecnativa/docker-postgres-autoconf' && (env.IS_PR || github.ref == 'refs/heads/master')
64
71
env :
65
72
REGISTRY_HOST : docker.io
66
73
REGISTRY_TOKEN : ${{ secrets.DOCKERHUB_TOKEN }}
67
74
REGISTRY_USERNAME : ${{ secrets.DOCKERHUB_LOGIN }}
68
75
run : ./hooks/push
69
- - name : push to github registry
70
- if : github.repository == 'Tecnativa/docker-postgres-autoconf' && github.ref == 'refs/heads/master'
76
+ - name : Push Docker Image to GitHub Registry
77
+ if : github.repository == 'Tecnativa/docker-postgres-autoconf' && (env.IS_PR || github.ref == 'refs/heads/master')
71
78
env :
72
79
REGISTRY_HOST : ghcr.io
73
80
REGISTRY_TOKEN : ${{ secrets.BOT_TOKEN }}
0 commit comments