2022-04-26 20:22:16 +03:00
|
|
|
name: assets-release
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
2022-04-27 15:45:22 +03:00
|
|
|
paths-ignore:
|
2022-04-29 14:58:59 +03:00
|
|
|
- .github/**
|
|
|
|
- scripts/**
|
2022-04-26 20:22:16 +03:00
|
|
|
schedule:
|
|
|
|
- cron: '30 6 * * *'
|
|
|
|
workflow_dispatch:
|
|
|
|
inputs:
|
|
|
|
asset_dirs:
|
2022-05-20 20:19:53 +03:00
|
|
|
description: Asset directories
|
|
|
|
default: .,!test,!scripts
|
2022-04-26 20:22:16 +03:00
|
|
|
required: true
|
|
|
|
|
|
|
|
concurrency: ${{ github.workflow }}
|
|
|
|
|
|
|
|
env:
|
2022-05-20 20:19:53 +03:00
|
|
|
default_asset_dirs: .,!test,!scripts
|
2022-04-26 20:22:16 +03:00
|
|
|
main_dir: main
|
|
|
|
release_dir: release
|
2022-05-20 20:19:53 +03:00
|
|
|
scripts_azureml_assets_dir: scripts/azureml-assets
|
|
|
|
scripts_assets_dir: scripts/azureml-assets/azureml/assets
|
|
|
|
scripts_environment_dir: scripts/azureml-assets/azureml/assets/environment
|
2022-04-26 20:22:16 +03:00
|
|
|
changed_assets_artifact: changed-assets
|
|
|
|
releasable_assets_artifact: releasable-assets
|
|
|
|
asset_config_filename: asset.yaml
|
|
|
|
|
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
shell: bash
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
identify-updated-assets:
|
|
|
|
name: Identify updated assets
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Clone branch
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
fetch-depth: 1
|
|
|
|
path: ${{ env.main_dir }}
|
|
|
|
|
|
|
|
- name: Clone release branch
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
ref: release
|
|
|
|
fetch-depth: 0
|
|
|
|
path: ${{ env.release_dir }}
|
|
|
|
|
|
|
|
- name: Use Python 3.8 or newer
|
|
|
|
uses: actions/setup-python@v3
|
|
|
|
with:
|
|
|
|
python-version: '>=3.8'
|
|
|
|
|
|
|
|
- name: Install dependencies
|
2022-05-20 20:19:53 +03:00
|
|
|
run: pip install -e $main_dir/$scripts_azureml_assets_dir
|
2022-04-26 20:22:16 +03:00
|
|
|
|
|
|
|
# TODO: Consider using Git to detect changes
|
|
|
|
- name: Find updated assets
|
|
|
|
id: find-updated-assets
|
2022-06-23 19:41:15 +03:00
|
|
|
run: python -u $scripts_assets_dir/update_assets.py -i "${{ github.event.inputs.asset_dirs || env.default_asset_dirs }}" -r ${{ github.workspace }}/$release_dir -o ${{ runner.temp }}/$changed_assets_artifact
|
2022-05-20 20:19:53 +03:00
|
|
|
working-directory: ${{ env.main_dir }}
|
2022-04-26 20:22:16 +03:00
|
|
|
|
|
|
|
- name: Upload changed assets
|
|
|
|
uses: actions/upload-artifact@v3
|
2022-06-23 19:41:15 +03:00
|
|
|
if: steps.find-updated-assets.outputs.updated_count > 0
|
2022-04-26 20:22:16 +03:00
|
|
|
with:
|
|
|
|
name: ${{ env.changed_assets_artifact }}
|
|
|
|
path: ${{ runner.temp }}/${{ env.changed_assets_artifact }}
|
|
|
|
|
|
|
|
- name: Upload non-testable assets
|
|
|
|
uses: actions/upload-artifact@v3
|
2022-06-23 19:41:15 +03:00
|
|
|
if: steps.find-updated-assets.outputs.updated_count > 0
|
2022-04-26 20:22:16 +03:00
|
|
|
with:
|
|
|
|
name: ${{ env.releasable_assets_artifact }}
|
|
|
|
path: |
|
|
|
|
${{ runner.temp }}/${{ env.changed_assets_artifact }}
|
|
|
|
!${{ runner.temp }}/${{ env.changed_assets_artifact }}/environment
|
2022-06-23 19:41:15 +03:00
|
|
|
|
|
|
|
outputs:
|
|
|
|
updated_env_count: ${{ steps.find-updated-assets.outputs.updated_env_count }}
|
2022-04-26 20:22:16 +03:00
|
|
|
|
|
|
|
build-images:
|
|
|
|
name: Build and test images
|
2022-06-23 19:41:15 +03:00
|
|
|
if: needs.identify-updated-assets.outputs.updated_env_count > 0
|
2022-05-28 03:58:09 +03:00
|
|
|
runs-on: ubuntu-latest
|
2022-04-26 20:22:16 +03:00
|
|
|
needs: identify-updated-assets
|
2022-05-25 23:10:55 +03:00
|
|
|
environment: BuiltinRegistryDev
|
2022-04-26 20:22:16 +03:00
|
|
|
|
|
|
|
env:
|
2022-04-26 20:26:59 +03:00
|
|
|
build_logs_artifact_name: build-logs
|
2022-04-26 20:22:16 +03:00
|
|
|
tested_dir: tested-environments
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Download changed assets
|
|
|
|
uses: actions/download-artifact@v3
|
|
|
|
with:
|
|
|
|
name: ${{ env.changed_assets_artifact }}
|
|
|
|
path: ${{ runner.temp }}/${{ env.changed_assets_artifact }}
|
|
|
|
|
|
|
|
- name: Clone branch
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
fetch-depth: 1
|
|
|
|
path: ${{ env.main_dir }}
|
|
|
|
|
|
|
|
- name: Use Python 3.8 or newer
|
|
|
|
uses: actions/setup-python@v3
|
|
|
|
with:
|
|
|
|
python-version: '>=3.8'
|
|
|
|
|
|
|
|
- name: Install dependencies
|
2022-05-20 20:19:53 +03:00
|
|
|
run: pip install -e $main_dir/$scripts_azureml_assets_dir
|
2022-05-25 23:10:55 +03:00
|
|
|
|
|
|
|
- name: Log in to Azure
|
|
|
|
uses: azure/login@v1
|
|
|
|
with:
|
|
|
|
creds: ${{ secrets.AZ_CREDS_BUILTINREGISTRYDEV }}
|
2022-04-26 20:22:16 +03:00
|
|
|
|
2022-05-25 23:10:55 +03:00
|
|
|
- name: Build and test images
|
2022-04-26 20:22:16 +03:00
|
|
|
id: build-images
|
2022-05-28 03:58:09 +03:00
|
|
|
run: python -u $main_dir/$scripts_environment_dir/build.py -i '${{ runner.temp }}'/$changed_assets_artifact -a $asset_config_filename -o '${{ runner.temp }}'/$tested_dir -l '${{ runner.temp }}'/$build_logs_artifact_name -g ${{ secrets.RESOURCE_GROUP }} -r ${{ secrets.BUILD_CONTAINER_REGISTRY }} -T 'python -V'
|
2022-04-26 20:26:59 +03:00
|
|
|
continue-on-error: true
|
2022-05-25 23:10:55 +03:00
|
|
|
|
2022-04-26 20:22:16 +03:00
|
|
|
- name: Upload build logs
|
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
if: always()
|
|
|
|
with:
|
2022-04-26 20:26:59 +03:00
|
|
|
name: ${{ env.build_logs_artifact_name }}
|
|
|
|
path: ${{ runner.temp }}/${{ env.build_logs_artifact_name }}
|
2022-04-26 20:22:16 +03:00
|
|
|
|
|
|
|
- name: Upload tested assets
|
2022-05-25 23:10:55 +03:00
|
|
|
if: steps.build-images.outputs.success_count > 0
|
2022-04-26 20:22:16 +03:00
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
name: ${{ env.releasable_assets_artifact }}
|
|
|
|
path: ${{ runner.temp }}/${{ env.tested_dir }}
|
|
|
|
|
|
|
|
check-release-assets:
|
|
|
|
name: Check releaseable assets
|
|
|
|
if: always()
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs:
|
|
|
|
- identify-updated-assets
|
|
|
|
- build-images
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Download releasable assets
|
|
|
|
id: download-artifact
|
|
|
|
uses: actions/download-artifact@v3
|
|
|
|
with:
|
|
|
|
name: ${{ env.releasable_assets_artifact }}
|
|
|
|
path: ${{ runner.temp }}/${{ env.releasable_assets_artifact }}
|
|
|
|
continue-on-error: true
|
|
|
|
|
|
|
|
outputs:
|
|
|
|
has_releasable_assets: ${{ steps.download-artifact.outputs.download-path }}
|
2022-04-28 06:26:12 +03:00
|
|
|
|
2022-04-26 20:22:16 +03:00
|
|
|
release-assets:
|
|
|
|
name: Release assets
|
2022-05-02 18:39:59 +03:00
|
|
|
if: always() && needs.check-release-assets.outputs.has_releasable_assets != '' && github.ref == 'refs/heads/main'
|
2022-04-26 20:22:16 +03:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: check-release-assets
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Download releasable assets
|
|
|
|
id: download-artifact
|
|
|
|
uses: actions/download-artifact@v3
|
|
|
|
with:
|
|
|
|
name: ${{ env.releasable_assets_artifact }}
|
|
|
|
path: ${{ runner.temp }}/${{ env.releasable_assets_artifact }}
|
|
|
|
|
|
|
|
- name: Clone branch
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
fetch-depth: 1
|
|
|
|
path: ${{ env.main_dir }}
|
|
|
|
|
|
|
|
- name: Clone release branch
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
if: steps.download-artifact.outputs.download-path
|
|
|
|
with:
|
|
|
|
ref: release
|
|
|
|
fetch-depth: 0
|
|
|
|
path: ${{ env.release_dir }}
|
|
|
|
|
|
|
|
# TODO: Not needed unless calling update_assets.py
|
|
|
|
- name: Use Python 3.8 or newer
|
|
|
|
uses: actions/setup-python@v3
|
|
|
|
with:
|
|
|
|
python-version: '>=3.8'
|
|
|
|
|
|
|
|
- name: Install dependencies
|
2022-05-20 20:19:53 +03:00
|
|
|
run: pip install -e $main_dir/$scripts_azureml_assets_dir
|
2022-04-26 20:22:16 +03:00
|
|
|
|
|
|
|
# TODO: This is overkill, just copy directories without involving this script
|
|
|
|
- name: Update release branch
|
2022-06-14 17:43:26 +03:00
|
|
|
run: python -u $main_dir/$scripts_assets_dir/update_assets.py -i ${{ runner.temp }}/$releasable_assets_artifact -r $release_dir -c
|
2022-04-26 20:22:16 +03:00
|
|
|
|
|
|
|
- name: Create commit and push
|
|
|
|
run: |
|
|
|
|
if [[ -z $(git status -s) ]]; then
|
|
|
|
echo "No updates to the release branch"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
git config user.email "<>"
|
|
|
|
git config user.name "$GITHUB_WORKFLOW"
|
|
|
|
git add -A .
|
|
|
|
git commit -m "Release $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
|
|
|
|
git push
|
|
|
|
working-directory: ${{ env.release_dir }}
|