-
Notifications
You must be signed in to change notification settings - Fork 59
91 lines (82 loc) · 2.83 KB
/
preset-image-build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: Build and Push Preset Models
on:
pull_request:
branches:
- main
paths:
- 'presets/models/**'
push:
branches:
- main
paths:
- 'presets/models/**'
workflow_dispatch:
inputs:
image_tag_name:
description: 'Image Tag'
required: true
permissions:
id-token: write
contents: read
env:
VERSION: 0.0.1
jobs:
setup:
runs-on: [self-hosted, 'username:runner-2']
outputs:
image_tag: ${{ steps.set_tag.outputs.image_tag }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: Check Available Disk Space
run: df -h
- name: Set Image Tag
id: set_tag
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" && -n "${{ github.event.inputs.image_tag_name }}" ]]; then
echo "Using workflow dispatch to set image tag"
echo "image_tag=${{ github.event.inputs.image_tag_name }}" >> $GITHUB_OUTPUT
else
echo "Setting image tag based on version set"
echo "image_tag=${{ env.VERSION }}" >> $GITHUB_OUTPUT
fi
- name: Print Image Tag
run: |
echo "image_tag for this job: ${{ steps.set_tag.outputs.image_tag }}"
- name: 'Get ACR Info'
id: acr_info
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" && -n "${{ github.event.inputs.image_tag_name }}" ]]; then
ACR_NAME="aimodelsregistry"
ACR_USERNAME=${{ secrets.ACR_AMR_USERNAME }}
ACR_PASSWORD=${{ secrets.ACR_AMR_PASSWORD }}
else
ACR_NAME="aimodelsregistrytest"
ACR_USERNAME=${{ secrets.ACR_AMRT_USERNAME }}
ACR_PASSWORD=${{ secrets.ACR_AMRT_PASSWORD }}
fi
echo "ACR_NAME=$ACR_NAME" >> $GITHUB_OUTPUT
echo "ACR_USERNAME=$ACR_USERNAME" >> $GITHUB_OUTPUT
echo "ACR_PASSWORD=$ACR_PASSWORD" >> $GITHUB_OUTPUT
- name: Launch Python Script to Kickoff Build Jobs
id: launch_script
run: |
IMAGE_TAG=${{ steps.set_tag.outputs.image_tag }} \
PR_BRANCH=${{ github.head_ref }} \
ACR_NAME=${{ steps.acr_info.outputs.ACR_NAME }} \
ACR_USERNAME=${{ steps.acr_info.outputs.ACR_USERNAME }} \
ACR_PASSWORD=${{ steps.acr_info.outputs.ACR_PASSWORD }} \
python3 .github/workflows/kind-cluster/main.py
# Check the exit status of the Python script
- name: Check Python Script Status
if: ${{ always() }}
run: |
if [ "${{ steps.launch_script.outcome }}" != "success" ]; then
echo "Python script failed to execute successfully."
exit 1 # Fail the job
else
echo "Python script executed successfully."
fi