Skip to content

update serialization #1

update serialization

update serialization #1

name: Serialize & Register Docs Examples
on:
workflow_call:
inputs:
packages:
description: "Packages"
required: true
type: string
secrets:
FLYTE_BOT_PAT:
required: true
defaults:
run:
# https://github.com/actions/runner/issues/241#issuecomment-577360161
shell: 'script -q -e -c "bash {0}"'
jobs:
# Use matrix strategy to run serialize for all directories in parallel. This also uploads the examples as artifacts
# for the workflow.
serialize:
name: Serialize Example
runs-on: ubuntu-latest
strategy:
matrix:
directory: "${{ fromJson(inputs.packages) }}"
steps:
- uses: actions/checkout@v2
with:
fetch-depth: "0"
- name: 'Set example id'
id: example_id
run: echo "EXAMPLE_ID=$(echo ${{ matrix.directory }} | sed 's@/@-@g' | sed 's@_@-@g' )" >> "$GITHUB_OUTPUT"
- name: 'Image version'
id: example_name
run: echo "EXAMPLE_NAME=$(basename -- ${{ matrix.directory }})" >> "$GITHUB_OUTPUT"
- name: Build docker image and serialize examples
# NOTE: the additional images are for the multi-image containerization examples
run: |
cd ${{ matrix.directory }}
image_uri=ghcr.io/flyteorg/flyte-examples:${{ steps.example_name.outputs.EXAMPLE_NAME }}-${{ github.sha }}
docker build . -t $image_uri
mkdir ./flyte_proto
docker run -i --rm -v $(pwd):/root $image_uri \
pyflyte --pkgs ${{ steps.example_name.outputs.EXAMPLE_NAME }} \
package \
--image $image_uri \
--image mindmeld="ghcr.io/flyteorg/flytecookbook:core-latest" \
--image borebuster="ghcr.io/flyteorg/flytekit:py3.9-latest" \
--output ./flyte-package.tgz
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: snacks-${{ steps.example_id.outputs.EXAMPLE_ID }}
path: ${{ matrix.directory }}/flyte-package.tgz
# Download all artifacts generated from the previous job. Startup a sandbox cluster then register all of them.
register:
name: Register example to sandbox
runs-on: ubuntu-latest
needs: ["serialize"]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: "0"
- uses: unionai/flytectl-setup-action@v0.0.1
- name: setup download artifact dir
run: |
mkdir download-artifact
- name: Download artifacts
uses: actions/download-artifact@v2
with:
path: ./download-artifact/
- name: setup sandbox
run: |
make setup
- name: Register examples
uses: unionai/flyte-register-action@v0.0.2
run: |
for file in ./download-artifact/**/*; do
flytectl register files \
--project flytesnacks \
--domain development \
--version latest \
--archive $file
done