Start using matrix in reuseable workflows directly (#1822)

* Start using matrix in reuseable workflows directly

* Fix name
This commit is contained in:
Ayaz Salikhov
2022-11-01 15:43:09 +04:00
committed by GitHub
parent 509d2afd0c
commit 5168eb6548
3 changed files with 54 additions and 56 deletions

View File

@@ -6,8 +6,8 @@ env:
on: on:
workflow_call: workflow_call:
inputs: inputs:
images: image:
description: Stringified JSON object listing image names description: Image name
required: true required: true
type: string type: string
secrets: secrets:
@@ -20,10 +20,6 @@ jobs:
merge-tags: merge-tags:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy:
matrix:
image: ${{ fromJson(inputs.images) }}
steps: steps:
- name: Checkout Repo ⚡️ - name: Checkout Repo ⚡️
uses: actions/checkout@v3 uses: actions/checkout@v3
@@ -35,18 +31,18 @@ jobs:
- name: Download x86_64 tags file 📥 - name: Download x86_64 tags file 📥
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
with: with:
name: ${{ matrix.image }}-x86_64-tags name: ${{ inputs.image }}-x86_64-tags
path: /tmp/tags/ path: /tmp/tags/
- name: Download aarch64 tags file 📥 - name: Download aarch64 tags file 📥
if: matrix.image != 'tensorflow-notebook' if: inputs.image != 'tensorflow-notebook'
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
with: with:
name: ${{ matrix.image }}-aarch64-tags name: ${{ inputs.image }}-aarch64-tags
path: /tmp/tags/ path: /tmp/tags/
- name: Create an empty aarch64 tags file for tensorflow-notebook 💩 - 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 run: touch /tmp/tags/aarch64-tensorflow-notebook.txt
shell: bash shell: bash
@@ -68,5 +64,5 @@ jobs:
- name: Merge tags for the images 🔀 - name: Merge tags for the images 🔀
if: github.ref == 'refs/heads/main' || github.event_name == 'schedule' 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 shell: bash

View File

@@ -6,8 +6,8 @@ env:
on: on:
workflow_call: workflow_call:
inputs: inputs:
images: image:
description: Stringified JSON object listing image names description: Image name
required: true required: true
type: string type: string
platform: platform:
@@ -24,10 +24,6 @@ jobs:
tag-manifest-push: tag-manifest-push:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy:
matrix:
image: ${{ fromJson(inputs.images) }}
steps: steps:
- name: Checkout Repo ⚡️ - name: Checkout Repo ⚡️
uses: actions/checkout@v3 uses: actions/checkout@v3
@@ -38,7 +34,7 @@ jobs:
- name: Load image to Docker 📥 - name: Load image to Docker 📥
uses: ./.github/actions/load-image uses: ./.github/actions/load-image
with: with:
image: ${{ matrix.image }} image: ${{ inputs.image }}
platform: ${{ inputs.platform }} platform: ${{ inputs.platform }}
- name: Login to Docker Hub 🔐 - name: Login to Docker Hub 🔐
@@ -51,12 +47,12 @@ jobs:
- name: Download tags file 📥 - name: Download tags file 📥
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
with: with:
name: ${{ matrix.image }}-${{ inputs.platform }}-tags name: ${{ inputs.image }}-${{ inputs.platform }}-tags
path: /tmp/tags/ path: /tmp/tags/
- name: Apply tags to the loaded image 🏷 - 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 📤 - name: Push Images to Docker Hub 📤
if: github.ref == 'refs/heads/main' || github.event_name == 'schedule' 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 shell: bash

View File

@@ -214,22 +214,22 @@ jobs:
aarch64-pyspark, aarch64-pyspark,
aarch64-all-spark, 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 uses: ./.github/workflows/docker-tag-manifest-push.yml
with: with:
platform: aarch64 platform: aarch64
# https://docs.github.com/en/actions/using-workflows/reusing-workflows#limitations image: ${{ matrix.image }}
# 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"
]
x86_64-images-tag-push: x86_64-images-tag-push:
secrets: secrets:
@@ -246,39 +246,45 @@ jobs:
x86_64-pyspark, x86_64-pyspark,
x86_64-all-spark, 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 uses: ./.github/workflows/docker-tag-manifest-push.yml
with: with:
platform: x86_64 platform: x86_64
images: >- image: ${{ matrix.image }}
[
"base-notebook",
"minimal-notebook",
"scipy-notebook",
"r-notebook",
"tensorflow-notebook",
"datascience-notebook",
"pyspark-notebook",
"all-spark-notebook"
]
merge-tags: merge-tags:
secrets: secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
needs: [aarch64-images-tag-push, x86_64-images-tag-push] 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 uses: ./.github/workflows/docker-merge-tags.yml
with: with:
images: >- image: ${{ matrix.image }}
[
"base-notebook",
"minimal-notebook",
"scipy-notebook",
"r-notebook",
"tensorflow-notebook",
"datascience-notebook",
"pyspark-notebook",
"all-spark-notebook"
]
wiki-update: wiki-update:
permissions: permissions: