-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
80 lines (74 loc) · 2.64 KB
/
action.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
name: 'Publish Kernel in AdaLab'
description: 'An action to publish a Docker image as a new kernel in AdaLab'
inputs:
kernel_name:
description: 'Name of the kernel'
required: true
kernel_description:
description: 'Description of the kernel'
required: true
harbor_registry_url:
description: 'AdaLab Harbor registry URL'
required: true
harbor_password:
description: 'Password for the AdaLab Harbor registry'
required: true
harbor_robot_user:
description: 'AdaLab Harbor registry robot user'
required: true
image_name:
description: 'Name of the Docker image'
required: true
image_tag:
description: 'Tag of the Docker image'
required: true
adalab_user_token:
description: 'User token for AdaLab API'
required: true
adalab_username:
description: 'Username for AdaLab API'
required: true
adalab_api_url:
description: 'AdaLab API URL'
required: true
runs:
using: 'composite'
steps:
- name: Log in to AdaLab Docker registry
shell: bash
run: |
echo "${{ inputs.harbor_password }}" | docker login -u '${{ inputs.harbor_robot_user }}' --password-stdin "${{ inputs.harbor_registry_url }}"
- name: Push Docker image
shell: bash
run: |
docker tag ${{ inputs.image_name }}:${{ inputs.image_tag }} ${{ inputs.harbor_registry_url }}/kernels_temp/${{ inputs.image_name }}:${{ inputs.image_tag }}
docker push ${{ inputs.harbor_registry_url }}/kernels_temp/${{ inputs.image_name }}:${{ inputs.image_tag }}
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
shell: bash
run: |
python -m pip install --upgrade pip
pip install --extra-index-url https://staging-adalab.adamatics.io/devpi/admin/adalib-dev adalib
- name: Register image as new kernel
shell: bash
run: |
python <<EOF
from adalib_auth import config
adalib_config = config.get_config(adaboard_api_url="${{ inputs.adalab_api_url }}", token="${{ inputs.adalab_user_token }}")
import adalib.harbor as harbor
harbor.create_image_metadata(
source_type="registry",
source_repository="${{ inputs.image_name }}",
source_tag="${{ inputs.image_tag }}",
project_name="kernels",
repository_name="${{ inputs.image_name }}",
tag="${{ inputs.image_tag }}",
type_id="kernel",
name="${{ inputs.kernel_name }}",
description="${{ inputs.kernel_description }}",
username="${{ inputs.adalab_username }}",
)
EOF