Skip to content

Scheduled Re-Build Images #966

Scheduled Re-Build Images

Scheduled Re-Build Images #966

# Copyright 2023 Iguazio
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Scheduled Re-Build Images
permissions:
contents: read
on:
schedule:
# every night at 2am
- cron: "0 2 * * *"
jobs:
resolve-branch-to-rebuild:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-branch.outputs.matrix }}
steps:
- name: Resolve Branch to Re-Build
id: set-branch
run: |
# take mlrun branches, find branches that are in format of 9.9.x (where 9 could by any number)
# sort them - so latest version would be last
# take last 2 elements (aka last 2 versions)
# wrap each name with "" and join with ,
# join with development
# output would be like - 1.3.x,1.4.x,development
branches=$(curl --retry 3 --retry-all-errors --silent https://api.github.com/repos/mlrun/mlrun/branches \
| jq -r '.[].name | select(test("^\\d+\\.\\d+\\.x$"))' \
| sort -Vr \
| head -2 \
| jq --raw-input --slurp --compact-output 'split("\n") | map(select(length > 0)) | . + ["development"]')
matrix=$(jq --compact-output --null-input --argjson branches "$branches" '{"repo": ["mlrun","ui"], "branch": $branches}')
echo "matrix=$(echo $matrix)" >> $GITHUB_OUTPUT
re-build-images:
if: github.repository == 'mlrun/mlrun'
needs: resolve-branch-to-rebuild
strategy:
fail-fast: false
matrix: ${{fromJson(needs.resolve-branch-to-rebuild.outputs.matrix)}}
runs-on: ubuntu-latest
steps:
# TODO: move to reuseable workflow once all branches have backported with the new workflow
- name: Generate GitHub App Token
id: app-token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
owner: mlrun
repositories: mlrun,ui
- name: Re-Build MLRun Image
if: matrix.repo == 'mlrun'
uses: convictional/trigger-workflow-and-wait@f69fa9eedd3c62a599220f4d5745230e237904be # 1.6.5
with:
owner: mlrun
repo: mlrun
github_token: ${{ steps.app-token.outputs.token }}
workflow_file_name: build.yaml
ref: ${{ matrix.branch }}
wait_interval: 60
# models is removed on 1.5.x but still exists on 1.4.x and 1.3.x
client_payload: '{"skip_images": "models,tests", "build_from_cache": "false"}'
- name: Re-Build UI Image
if: matrix.repo == 'ui'
uses: convictional/trigger-workflow-and-wait@f69fa9eedd3c62a599220f4d5745230e237904be # 1.6.5
with:
owner: mlrun
repo: ui
github_token: ${{ steps.app-token.outputs.token }}
workflow_file_name: build.yaml
ref: ${{ matrix.branch }}
wait_interval: 60