Skip to content

Commit 4714712

Browse files
[IMP] Add pushing PR images to be able to test it correctly
1 parent 80ddfb7 commit 4714712

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

.github/workflows/ci.yaml

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@ jobs:
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
@@ -32,7 +30,6 @@ jobs:
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,37 @@ 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
5046
DOCKER_TAG: ${{ matrix.pg_version }}-alpine
5147
GIT_SHA1: ${{ github.sha }}
48+
IS_PR: ${{ github.event_name == 'pull_request' }}
5249
steps:
53-
# Prepare
5450
- uses: actions/checkout@v2
5551
- uses: actions/setup-python@v1
5652
- run: pip install -r tests/ci-requirements.txt
53+
5754
# Build images
5855
- run: ./hooks/build
5956
# Test
6057
- 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+
docker tag ${{ env.DOCKER_REPO }}:${{ matrix.pg_version }}-alpine ${{ env.DOCKER_REPO }}:${{ DOCKER_TAG }}
63+
else
64+
echo "DOCKER_TAG=${{ matrix.pg_version }}-alpine" >> $GITHUB_ENV
65+
fi
6166
# Push
62-
- name: push to docker hub
63-
if: github.repository == 'Tecnativa/docker-postgres-autoconf' && github.ref == 'refs/heads/master'
67+
- name: Push Docker Image to Docker Hub
68+
if: github.repository == 'Tecnativa/docker-postgres-autoconf' && (env.IS_PR || github.ref == 'refs/heads/master')
6469
env:
6570
REGISTRY_HOST: docker.io
6671
REGISTRY_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
6772
REGISTRY_USERNAME: ${{ secrets.DOCKERHUB_LOGIN }}
6873
run: ./hooks/push
69-
- name: push to github registry
70-
if: github.repository == 'Tecnativa/docker-postgres-autoconf' && github.ref == 'refs/heads/master'
74+
- name: Push Docker Image to GitHub Registry
75+
if: github.repository == 'Tecnativa/docker-postgres-autoconf' && (env.IS_PR || github.ref == 'refs/heads/master')
7176
env:
7277
REGISTRY_HOST: ghcr.io
7378
REGISTRY_TOKEN: ${{ secrets.BOT_TOKEN }}

0 commit comments

Comments
 (0)