Skip to content

Commit

Permalink
Start using matrix in reuseable workflows directly (#1822)
Browse files Browse the repository at this point in the history
* Start using matrix in reuseable workflows directly

* Fix name
  • Loading branch information
mathbunnyru committed Nov 1, 2022
1 parent 509d2af commit 5168eb6
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 56 deletions.
18 changes: 7 additions & 11 deletions .github/workflows/docker-merge-tags.yml
Expand Up @@ -6,8 +6,8 @@ env:
on:
workflow_call:
inputs:
images:
description: Stringified JSON object listing image names
image:
description: Image name
required: true
type: string
secrets:
Expand All @@ -20,10 +20,6 @@ jobs:
merge-tags:
runs-on: ubuntu-latest

strategy:
matrix:
image: ${{ fromJson(inputs.images) }}

steps:
- name: Checkout Repo ⚡️
uses: actions/checkout@v3
Expand All @@ -35,18 +31,18 @@ jobs:
- name: Download x86_64 tags file 📥
uses: actions/download-artifact@v3
with:
name: ${{ matrix.image }}-x86_64-tags
name: ${{ inputs.image }}-x86_64-tags
path: /tmp/tags/

- name: Download aarch64 tags file 📥
if: matrix.image != 'tensorflow-notebook'
if: inputs.image != 'tensorflow-notebook'
uses: actions/download-artifact@v3
with:
name: ${{ matrix.image }}-aarch64-tags
name: ${{ inputs.image }}-aarch64-tags
path: /tmp/tags/

- name: Create an empty aarch64 tags file for tensorflow-notebook 💩
if: matrix.image == 'tensorflow-notebook'
if: inputs.image == 'tensorflow-notebook'
run: touch /tmp/tags/aarch64-tensorflow-notebook.txt
shell: bash

Expand All @@ -68,5 +64,5 @@ jobs:

- name: Merge tags for the images 🔀
if: github.ref == 'refs/heads/main' || github.event_name == 'schedule'
run: python3 -m tagging.merge_tags --short-image-name ${{ matrix.image }} --tags-dir /tmp/tags/
run: python3 -m tagging.merge_tags --short-image-name ${{ inputs.image }} --tags-dir /tmp/tags/
shell: bash
16 changes: 6 additions & 10 deletions .github/workflows/docker-tag-manifest-push.yml
Expand Up @@ -6,8 +6,8 @@ env:
on:
workflow_call:
inputs:
images:
description: Stringified JSON object listing image names
image:
description: Image name
required: true
type: string
platform:
Expand All @@ -24,10 +24,6 @@ jobs:
tag-manifest-push:
runs-on: ubuntu-latest

strategy:
matrix:
image: ${{ fromJson(inputs.images) }}

steps:
- name: Checkout Repo ⚡️
uses: actions/checkout@v3
Expand All @@ -38,7 +34,7 @@ jobs:
- name: Load image to Docker 📥
uses: ./.github/actions/load-image
with:
image: ${{ matrix.image }}
image: ${{ inputs.image }}
platform: ${{ inputs.platform }}

- name: Login to Docker Hub 🔐
Expand All @@ -51,12 +47,12 @@ jobs:
- name: Download tags file 📥
uses: actions/download-artifact@v3
with:
name: ${{ matrix.image }}-${{ inputs.platform }}-tags
name: ${{ inputs.image }}-${{ inputs.platform }}-tags
path: /tmp/tags/
- name: Apply tags to the loaded image 🏷
run: python3 -m tagging.apply_tags --short-image-name ${{ matrix.image }} --tags-dir /tmp/tags/ --platform ${{ inputs.platform }} --owner ${{ env.OWNER }}
run: python3 -m tagging.apply_tags --short-image-name ${{ inputs.image }} --tags-dir /tmp/tags/ --platform ${{ inputs.platform }} --owner ${{ env.OWNER }}

- name: Push Images to Docker Hub 📤
if: github.ref == 'refs/heads/main' || github.event_name == 'schedule'
run: docker push --all-tags ${{ env.OWNER }}/${{ matrix.image }}
run: docker push --all-tags ${{ env.OWNER }}/${{ inputs.image }}
shell: bash
76 changes: 41 additions & 35 deletions .github/workflows/docker.yml
Expand Up @@ -214,22 +214,22 @@ jobs:
aarch64-pyspark,
aarch64-all-spark,
]
strategy:
matrix:
image:
[
base-notebook,
minimal-notebook,
scipy-notebook,
r-notebook,
datascience-notebook,
pyspark-notebook,
all-spark-notebook,
]
uses: ./.github/workflows/docker-tag-manifest-push.yml
with:
platform: aarch64
# https://docs.github.com/en/actions/using-workflows/reusing-workflows#limitations
# The strategy property is not supported in any job that calls a reusable workflow
# Using the workaround: https://github.community/t/reusable-workflow-with-strategy-matrix/205676/2
images: >-
[
"base-notebook",
"minimal-notebook",
"scipy-notebook",
"r-notebook",
"datascience-notebook",
"pyspark-notebook",
"all-spark-notebook"
]
image: ${{ matrix.image }}

x86_64-images-tag-push:
secrets:
Expand All @@ -246,39 +246,45 @@ jobs:
x86_64-pyspark,
x86_64-all-spark,
]
strategy:
matrix:
image:
[
base-notebook,
minimal-notebook,
scipy-notebook,
r-notebook,
tensorflow-notebook,
datascience-notebook,
pyspark-notebook,
all-spark-notebook,
]
uses: ./.github/workflows/docker-tag-manifest-push.yml
with:
platform: x86_64
images: >-
[
"base-notebook",
"minimal-notebook",
"scipy-notebook",
"r-notebook",
"tensorflow-notebook",
"datascience-notebook",
"pyspark-notebook",
"all-spark-notebook"
]
image: ${{ matrix.image }}

merge-tags:
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
needs: [aarch64-images-tag-push, x86_64-images-tag-push]
strategy:
matrix:
image:
[
base-notebook,
minimal-notebook,
scipy-notebook,
r-notebook,
tensorflow-notebook,
datascience-notebook,
pyspark-notebook,
all-spark-notebook,
]
uses: ./.github/workflows/docker-merge-tags.yml
with:
images: >-
[
"base-notebook",
"minimal-notebook",
"scipy-notebook",
"r-notebook",
"tensorflow-notebook",
"datascience-notebook",
"pyspark-notebook",
"all-spark-notebook"
]
image: ${{ matrix.image }}

wiki-update:
permissions:
Expand Down

0 comments on commit 5168eb6

Please sign in to comment.