Skip to content

Commit 91a4d5f

Browse files
committed
Update workflow to have one github action worker per base image
1 parent f575819 commit 91a4d5f

1 file changed

Lines changed: 35 additions & 23 deletions

File tree

.github/workflows/publish.yml

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,20 @@ on:
77
- master
88

99
jobs:
10-
publish_base:
10+
list_base_images:
1111
runs-on: ubuntu-latest
12+
outputs:
13+
versions: ${{ steps.set-versions.outputs.versions }}
14+
steps:
15+
- uses: actions/checkout@v2
16+
- id: set-matrix
17+
run: echo "versions=$(ls base/images/ | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
18+
19+
list_prestashop_images:
20+
runs-on: ubuntu-latest
21+
outputs:
22+
versions: ${{ steps.set-versions.outputs.versions }}
23+
base_has_changed: ${{ steps.changes.outputs.base }}
1224
steps:
1325
# Fetch versions to work for images
1426
- uses: actions/checkout@v2
@@ -17,47 +29,50 @@ jobs:
1729
with:
1830
python-version: 3.8
1931
- id: set-versions
20-
run: echo "::set-output name=versions::$(./get_json_versions.py)"
21-
22-
# Push image base
23-
- name: Login to Docker Hub
24-
uses: docker/login-action@v2
25-
with:
26-
username: ${{ secrets.DOCKERHUB_USERNAME }}
27-
password: ${{ secrets.DOCKERHUB_TOKEN }}
28-
## Check if there are modifications in the base/ directory
29-
## and store it in the variable `steps.changes.outputs.base`
30-
## The variable is built like: steps.{#id}.outputs.{#filter}
32+
run: echo "versions=$(./get_json_versions.py)" >> $GITHUB_OUTPUT
3133
- uses: dorny/paths-filter@v2
3234
id: changes
3335
with:
3436
filters: |
3537
base:
3638
- 'base/**'
3739
40+
publish_base_images:
41+
runs-on: ubuntu-latest
42+
strategy:
43+
matrix:
44+
manifest: ${{ fromJson(needs.list_prestashop_images.outputs.versions) }}
45+
steps:
46+
- name: Login to Docker Hub
47+
uses: docker/login-action@v2
48+
with:
49+
username: ${{ secrets.DOCKERHUB_USERNAME }}
50+
password: ${{ secrets.DOCKERHUB_TOKEN }}
51+
3852
- name: Base Images > Generate Tags
3953
run: ./generate_tags.sh
4054
working-directory: base
4155

4256
- name: Base Images > Docker Build Tags
43-
run: ./docker_tags.sh
57+
run: ./docker_tags.sh --version ${{ matrix.version }}
4458
if: ${{ github.event_name == 'pull_request' }}
4559
working-directory: base
4660

4761
- name: Base Images > Docker Build & Force Push
48-
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && steps.changes.outputs.base == 'true' }}
49-
run: ./docker_tags.sh -p -f
62+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && needs.list_prestashop_images.outputs.base_has_changed == 'true' }}
63+
run: ./docker_tags.sh -p -f --version ${{ matrix.version }}
5064
working-directory: base
51-
outputs:
52-
versions: ${{ steps.set-versions.outputs.versions }}
65+
5366

5467
publish_images:
5568
runs-on: ubuntu-latest
56-
needs: publish_base
69+
needs:
70+
list_prestashop_images
71+
publish_base_images
5772
strategy:
5873
fail-fast: false
5974
matrix:
60-
ps-version: ${{ fromJson(needs.publish_base.outputs.versions) }}
75+
ps-version: ${{ fromJson(needs.list_prestashop_images.outputs.versions) }}
6176
steps:
6277
- name: Login to Docker Hub
6378
uses: docker/login-action@v2
@@ -73,9 +88,6 @@ jobs:
7388
- name: Install dependencies
7489
run: pip install -r requirements.txt
7590

76-
- name: Build Docker images
77-
run: ./prestashop_docker.py --quiet tag build ${{ matrix.ps-version }} --force
78-
79-
- name: Push Docker images
91+
- name: Build & Push Docker images
8092
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
8193
run: ./prestashop_docker.py --quiet tag push ${{ matrix.ps-version }} --force

0 commit comments

Comments
 (0)