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/**
|
2022-04-26 20:22:16 +03:00
|
|
|
schedule:
|
|
|
|
- cron: '30 6 * * *'
|
|
|
|
workflow_dispatch:
|
|
|
|
|
|
|
|
concurrency: ${{ github.workflow }}
|
|
|
|
|
|
|
|
env:
|
2023-06-27 21:53:56 +03:00
|
|
|
asset_dirs: assets
|
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-12-29 00:25:12 +03:00
|
|
|
scripts_release_dir: scripts/release
|
2022-08-30 02:37:22 +03:00
|
|
|
scripts_setup_dir: scripts/setup
|
2022-12-29 00:25:12 +03:00
|
|
|
scripts_dir: scripts
|
2023-05-11 21:25:41 +03:00
|
|
|
asset_list_artifact: assets-list
|
|
|
|
asset_list_file: assets.txt
|
2022-04-26 20:22:16 +03:00
|
|
|
changed_assets_artifact: changed-assets
|
|
|
|
releasable_assets_artifact: releasable-assets
|
|
|
|
asset_config_filename: asset.yaml
|
|
|
|
|
2022-08-30 02:37:22 +03:00
|
|
|
permissions:
|
2023-02-22 17:04:14 +03:00
|
|
|
# Required to clone repo
|
|
|
|
contents: read
|
2022-08-30 02:37:22 +03:00
|
|
|
# Required for OIDC login to Azure
|
|
|
|
id-token: write
|
|
|
|
|
2022-04-26 20:22:16 +03:00
|
|
|
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 }}
|
|
|
|
|
2024-07-13 00:35:43 +03:00
|
|
|
- name: Use Python 3.10 or newer
|
2023-02-22 17:14:54 +03:00
|
|
|
uses: actions/setup-python@v4
|
2022-04-26 20:22:16 +03:00
|
|
|
with:
|
2024-07-13 00:35:43 +03:00
|
|
|
python-version: '>=3.10'
|
2022-04-26 20:22:16 +03:00
|
|
|
|
|
|
|
- name: Install dependencies
|
2022-05-20 20:19:53 +03:00
|
|
|
run: pip install -e $main_dir/$scripts_azureml_assets_dir
|
2023-05-25 22:46:04 +03:00
|
|
|
|
2022-04-26 20:22:16 +03:00
|
|
|
- name: Find updated assets
|
|
|
|
id: find-updated-assets
|
2023-05-25 22:46:04 +03:00
|
|
|
run: python -u $scripts_assets_dir/update_assets.py -i "$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 }}
|
2023-11-01 19:30:33 +03:00
|
|
|
# Remove this line and uncomment the one below after testing
|
|
|
|
# !${{ runner.temp }}/${{ env.changed_assets_artifact }}/environment
|
2023-05-11 21:25:41 +03:00
|
|
|
|
|
|
|
- name: Create list of assets
|
2023-05-25 22:46:04 +03:00
|
|
|
id: create-assets-list
|
2023-05-11 21:25:41 +03:00
|
|
|
run: |
|
|
|
|
artifact_dir=${{ runner.temp }}/$asset_list_artifact
|
|
|
|
mkdir -p $artifact_dir
|
2023-05-25 22:46:04 +03:00
|
|
|
python -u $scripts_assets_dir/asset_utils.py list -i "$asset_dirs" -o $artifact_dir/$asset_list_file
|
2023-05-11 21:25:41 +03:00
|
|
|
working-directory: ${{ env.main_dir }}
|
2023-05-25 22:46:04 +03:00
|
|
|
|
|
|
|
- name: Check list of assets
|
|
|
|
if: steps.create-assets-list.outputs.asset_count == 0
|
|
|
|
run: |
|
|
|
|
echo "::error::List of assets is empty. Please check the main branch and this workflow."
|
|
|
|
exit 1
|
|
|
|
|
2023-07-21 16:08:47 +03:00
|
|
|
- name: Upload list of assets
|
2023-05-11 21:25:41 +03:00
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
name: ${{ env.asset_list_artifact }}
|
|
|
|
path: ${{ runner.temp }}/${{ env.asset_list_artifact }}
|
2022-07-15 20:19:25 +03:00
|
|
|
|
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
|
|
|
|
2023-11-01 19:30:33 +03:00
|
|
|
# build-images:
|
|
|
|
# name: Build and test images
|
|
|
|
# if: needs.identify-updated-assets.outputs.updated_env_count > 0
|
|
|
|
# runs-on: ubuntu-latest
|
|
|
|
# needs: identify-updated-assets
|
|
|
|
# environment: Testing
|
|
|
|
|
|
|
|
# env:
|
|
|
|
# build_logs_artifact_name: build-logs
|
|
|
|
# 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 }}
|
2022-04-26 20:22:16 +03:00
|
|
|
|
2023-11-01 19:30:33 +03:00
|
|
|
# - name: Clone branch
|
|
|
|
# uses: actions/checkout@v3
|
|
|
|
# with:
|
|
|
|
# fetch-depth: 1
|
2022-04-26 20:22:16 +03:00
|
|
|
|
2023-11-01 19:30:33 +03:00
|
|
|
# - name: Use Python 3.8 or newer
|
|
|
|
# uses: actions/setup-python@v4
|
|
|
|
# with:
|
|
|
|
# python-version: '>=3.8'
|
2022-04-26 20:22:16 +03:00
|
|
|
|
2023-11-01 19:30:33 +03:00
|
|
|
# - name: Install dependencies
|
|
|
|
# run: pip install -e $scripts_azureml_assets_dir
|
|
|
|
|
|
|
|
# - name: Log in to Azure and create resources
|
|
|
|
# uses: ./.github/actions/create-azure-resources
|
|
|
|
# with:
|
|
|
|
# client-id: ${{ secrets.AZURE_CLIENT_ID }}
|
|
|
|
# tenant-id: ${{ secrets.AZURE_TENANT_ID }}
|
|
|
|
# subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
|
|
|
|
# scripts-setup-dir: ${{ env.scripts_setup_dir }}
|
2022-04-26 20:22:16 +03:00
|
|
|
|
2023-11-01 19:30:33 +03:00
|
|
|
# - name: Build and test images
|
|
|
|
# id: build-images
|
|
|
|
# run: python -u $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 $resource_group -r $container_registry -T 'python -V'
|
|
|
|
# continue-on-error: true
|
2022-05-25 23:10:55 +03:00
|
|
|
|
2023-11-01 19:30:33 +03:00
|
|
|
# - name: Upload build logs
|
|
|
|
# uses: actions/upload-artifact@v3
|
|
|
|
# if: always()
|
|
|
|
# with:
|
|
|
|
# name: ${{ env.build_logs_artifact_name }}
|
|
|
|
# path: ${{ runner.temp }}/${{ env.build_logs_artifact_name }}
|
2022-04-26 20:22:16 +03:00
|
|
|
|
2023-11-01 19:30:33 +03:00
|
|
|
# - name: Upload tested assets
|
|
|
|
# if: steps.build-images.outputs.success_count > 0
|
|
|
|
# uses: actions/upload-artifact@v3
|
|
|
|
# with:
|
|
|
|
# name: ${{ env.releasable_assets_artifact }}
|
|
|
|
# path: ${{ runner.temp }}/${{ env.tested_dir }}
|
2022-04-26 20:22:16 +03:00
|
|
|
|
|
|
|
check-release-assets:
|
|
|
|
name: Check releaseable assets
|
2023-07-18 18:40:33 +03:00
|
|
|
if: "!cancelled()"
|
2022-04-26 20:22:16 +03:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs:
|
|
|
|
- identify-updated-assets
|
2023-11-01 19:30:33 +03:00
|
|
|
# - build-images
|
2022-04-26 20:22:16 +03:00
|
|
|
|
|
|
|
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:
|
2023-07-21 16:08:47 +03:00
|
|
|
name: Update release branch
|
2023-07-18 18:40:33 +03:00
|
|
|
if: "!cancelled() && 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
|
2022-07-15 20:19:25 +03:00
|
|
|
if: needs.check-release-assets.outputs.has_releasable_assets != ''
|
2022-04-26 20:22:16 +03:00
|
|
|
id: download-artifact
|
|
|
|
uses: actions/download-artifact@v3
|
|
|
|
with:
|
|
|
|
name: ${{ env.releasable_assets_artifact }}
|
|
|
|
path: ${{ runner.temp }}/${{ env.releasable_assets_artifact }}
|
|
|
|
|
2023-05-11 21:25:41 +03:00
|
|
|
- name: Download list of assets
|
|
|
|
uses: actions/download-artifact@v3
|
|
|
|
with:
|
|
|
|
name: ${{ env.asset_list_artifact }}
|
|
|
|
path: ${{ runner.temp }}/${{ env.asset_list_artifact }}
|
|
|
|
|
2022-04-26 20:22:16 +03:00
|
|
|
- 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
|
2023-02-22 17:04:14 +03:00
|
|
|
token: ${{ secrets.AZUREML_BOT_PAT }}
|
2022-04-26 20:22:16 +03:00
|
|
|
path: ${{ env.release_dir }}
|
|
|
|
|
2024-07-13 00:35:43 +03:00
|
|
|
- name: Use Python 3.10 or newer
|
2023-02-22 17:14:54 +03:00
|
|
|
uses: actions/setup-python@v4
|
2022-04-26 20:22:16 +03:00
|
|
|
with:
|
2024-07-13 00:35:43 +03:00
|
|
|
python-version: '>=3.10'
|
2022-04-26 20:22:16 +03:00
|
|
|
|
|
|
|
- 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
|
|
|
|
|
|
|
- name: Update release branch
|
2022-07-29 21:12:57 +03:00
|
|
|
if: steps.download-artifact.outputs.download-path
|
2023-07-18 17:37:28 +03:00
|
|
|
run: python -u $main_dir/$scripts_assets_dir/copy_assets.py -i ${{ runner.temp }}/$releasable_assets_artifact -o $release_dir/latest
|
2022-04-26 20:22:16 +03:00
|
|
|
|
2023-05-11 21:25:41 +03:00
|
|
|
- name: Delete deprecated assets
|
|
|
|
run: python -u $main_dir/$scripts_assets_dir/asset_utils.py delete -i $release_dir -r ${{ runner.temp }}/$asset_list_artifact/$asset_list_file
|
|
|
|
|
2022-12-29 00:25:12 +03:00
|
|
|
- name: Copy test files and scripts
|
2022-08-17 20:54:21 +03:00
|
|
|
run: |
|
2023-06-27 21:53:56 +03:00
|
|
|
python -u $main_dir/$scripts_release_dir/test_file_convert.py -i "$asset_dirs" -r $release_dir -w $main_dir
|
2022-07-15 20:19:25 +03:00
|
|
|
|
2022-12-29 00:25:12 +03:00
|
|
|
- name: Copy scripts
|
2022-07-15 20:19:25 +03:00
|
|
|
run: |
|
2022-12-29 00:25:12 +03:00
|
|
|
rm -Rf $release_dir/$scripts_dir
|
|
|
|
cp -r $main_dir/$scripts_dir $release_dir/$scripts_dir
|
2022-07-15 20:19:25 +03:00
|
|
|
|
2023-02-22 03:11:06 +03:00
|
|
|
- name: Create commit and push
|
|
|
|
env:
|
|
|
|
GIT_AUTHOR_NAME: github-actions[bot]
|
|
|
|
GIT_AUTHOR_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com
|
|
|
|
GIT_COMMITTER_NAME: GitHub
|
|
|
|
GIT_COMMITTER_EMAIL: noreply@github.com
|
|
|
|
run: |
|
|
|
|
if [[ -z $(git status -s) ]]; then
|
|
|
|
echo "No updates to the release branch"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
git add -A .
|
|
|
|
git commit -m "Update release branch" -m "Automated updates made by [$GITHUB_WORKFLOW]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID)"
|
|
|
|
git push
|
|
|
|
working-directory: ${{ env.release_dir }}
|