Skip to content

Commit 12e305e

Browse files
Merge pull request #442 from Quetzacoalt91/build-then-push
Avoid API limit by querying Docker Hub unauthenticated in Github Actions, and build only if needed
2 parents e9669b3 + 7a78eb6 commit 12e305e

File tree

2 files changed

+43
-11
lines changed

2 files changed

+43
-11
lines changed

.github/workflows/publish.yml

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- uses: actions/checkout@v2
1717
- id: set-versions
1818
run: echo "versions=$(ls base/images/ | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
19-
- uses: dorny/paths-filter@v2
19+
- uses: dorny/paths-filter@v3
2020
id: changes
2121
with:
2222
filters: |
@@ -50,8 +50,14 @@ jobs:
5050
username: ${{ secrets.DOCKERHUB_USERNAME }}
5151
password: ${{ secrets.DOCKERHUB_TOKEN }}
5252

53+
- name: Set up QEMU
54+
uses: docker/setup-qemu-action@v3
55+
5356
- name: Enable multi-platform builds
54-
run: docker buildx create --name container --driver=docker-container
57+
uses: docker/setup-buildx-action@v3
58+
with:
59+
name: container
60+
version: latest
5561

5662
- uses: actions/checkout@v2
5763

@@ -75,30 +81,55 @@ jobs:
7581
needs:
7682
- list_prestashop_images
7783
- publish_base
84+
- list_base_images
7885
strategy:
7986
max-parallel: 2
8087
fail-fast: false
8188
matrix:
8289
ps-version: ${{ fromJson(needs.list_prestashop_images.outputs.versions) }}
8390
steps:
84-
- name: Login to Docker Hub
85-
uses: docker/login-action@v2
91+
- uses: actions/checkout@v2
92+
93+
- uses: dorny/paths-filter@v3
94+
id: filter
8695
with:
87-
username: ${{ secrets.DOCKERHUB_USERNAME }}
88-
password: ${{ secrets.DOCKERHUB_TOKEN }}
96+
filters: |
97+
image_has_changed:
98+
- 'images/${{ matrix.ps-version }}/**'
99+
100+
- name: Set up QEMU
101+
if: ${{ steps.filter.outputs.image_has_changed == 'true' }}
102+
uses: docker/setup-qemu-action@v3
89103

90104
- name: Enable multi-platform builds
91-
run: docker buildx create --name container --driver=docker-container
105+
if: ${{ steps.filter.outputs.image_has_changed == 'true' }}
106+
uses: docker/setup-buildx-action@v3
107+
with:
108+
name: container
109+
version: latest
92110

93-
- uses: actions/checkout@v2
94-
- name: Set up Python 3.8
111+
- name: Set up Python
112+
if: ${{ steps.filter.outputs.image_has_changed == 'true' }}
95113
uses: actions/setup-python@v2
96114
with:
97115
python-version: 3.9
116+
98117
- name: Install dependencies
118+
if: ${{ steps.filter.outputs.image_has_changed == 'true' }}
99119
run: pip install -r requirements.txt
100120

101-
- name: Build & Push Docker images
102-
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
121+
- name: Build Docker images
122+
if: ${{ steps.filter.outputs.image_has_changed == 'true' }}
123+
run: DOCKER_REPOSITORY=${{ vars.DOCKER_REPOSITORY}} ./prestashop_docker.py --quiet tag build ${{ matrix.ps-version }} --force
124+
125+
- name: Login to Docker Hub
126+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && (needs.list_base_images.outputs.base_has_changed == 'true' || steps.filter.outputs.image_has_changed == 'true') }}
127+
uses: docker/login-action@v2
128+
with:
129+
username: ${{ secrets.DOCKERHUB_USERNAME }}
130+
password: ${{ secrets.DOCKERHUB_TOKEN }}
131+
132+
- name: Build by using cache and push Docker images
133+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && (needs.list_base_images.outputs.base_has_changed == 'true' || steps.filter.outputs.image_has_changed == 'true') }}
103134
run: DOCKER_REPOSITORY=${{ vars.DOCKER_REPOSITORY}} ./prestashop_docker.py --quiet tag push ${{ matrix.ps-version }} --force
104135

prestashop_docker/tag_manager.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def build(self, version=None, force=False, push=False):
7171
"docker", "buildx", "build",
7272
"--platform", "linux/arm/v7,linux/arm64/v8,linux/amd64",
7373
"--builder", "container",
74+
"--progress", "plain",
7475
] + tags + args + [
7576
str(version_path)
7677
]

0 commit comments

Comments
 (0)