1616 - uses : actions/checkout@v2
1717 - uses : actions/setup-python@v1
1818 - 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
2321 - uses : actions/cache@v1
2422 with :
2523 path : ~/.cache/pre-commit
3230 strategy :
3331 fail-fast : false
3432 matrix :
35- # Test modern Odoo versions with latest Postgres version
3633 pg_version :
3734 - " 16"
3835 - " 15"
@@ -45,29 +42,35 @@ jobs:
4542 env :
4643 # Indicates what's the equivalent to tecnativa/postgres-autoconf:latest image
4744 LATEST_RELEASE : " 16-alpine"
48- # Variables found by default in Docker Hub builder
4945 DOCKER_REPO : tecnativa/postgres-autoconf
50- DOCKER_TAG : ${{ matrix.pg_version }}-alpine
5146 GIT_SHA1 : ${{ github.sha }}
47+ IS_PR : ${{ github.event_name == 'pull_request' }}
5248 steps :
53- # Prepare
5449 - uses : actions/checkout@v2
5550 - uses : actions/setup-python@v1
5651 - run : pip install -r tests/ci-requirements.txt
52+ - name : Set Docker Tag
53+ run : |
54+ if [ "${{ env.IS_PR }}" = "true" ]; then
55+ echo "DOCKER_TAG=${{ matrix.pg_version }}-test-pr${{ github.event.number }}" >> $GITHUB_ENV
56+ else
57+ echo "DOCKER_TAG=${{ matrix.pg_version }}-alpine" >> $GITHUB_ENV
58+ fi
59+
5760 # Build images
5861 - run : ./hooks/build
5962 # Test
6063 - run : python -m unittest tests.test -v
6164 # Push
62- - name : push to docker hub
63- if : github.repository == 'Tecnativa/docker-postgres-autoconf' && github.ref == 'refs/heads/master'
65+ - name : Push Docker Image to Docker Hub
66+ if : github.repository == 'Tecnativa/docker-postgres-autoconf' && (env.IS_PR || github.ref == 'refs/heads/master')
6467 env :
6568 REGISTRY_HOST : docker.io
6669 REGISTRY_TOKEN : ${{ secrets.DOCKERHUB_TOKEN }}
6770 REGISTRY_USERNAME : ${{ secrets.DOCKERHUB_LOGIN }}
6871 run : ./hooks/push
69- - name : push to github registry
70- if : github.repository == 'Tecnativa/docker-postgres-autoconf' && github.ref == 'refs/heads/master'
72+ - name : Push Docker Image to GitHub Registry
73+ if : github.repository == 'Tecnativa/docker-postgres-autoconf' && (env.IS_PR || github.ref == 'refs/heads/master')
7174 env :
7275 REGISTRY_HOST : ghcr.io
7376 REGISTRY_TOKEN : ${{ secrets.BOT_TOKEN }}
0 commit comments