-
Notifications
You must be signed in to change notification settings - Fork 5
80 lines (63 loc) · 2.85 KB
/
build_image.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
name: Build the GVMI image
on:
workflow_call:
inputs:
IS_TEST_BUILD:
description: Whether this run is a test build
required: True
type: boolean
IMAGE_PYTHON_VERSION:
description: Python version used in the GVMI image
required: True
type: string
REGISTRY_REPOSITORY:
description: The repository in the Golem Registry to upload the image to
required: True
type: string
secrets:
REGISTRY_USER:
required: True
REGISTRY_TOKEN:
required: True
jobs:
image_test:
name: Build the image
runs-on: [goth2]
steps:
- uses: actions/checkout@v4
- uses: Gr1N/setup-poetry@v9
- name: Install requirements
run: poetry install --no-ansi
- name: Get Ray-On-Golem version
run: echo "RAY_ON_GOLEM_VERSION=$(poetry version | sed 's/ray-on-golem //')" >> $GITHUB_ENV
- name: Get Ray version
run: echo "RAY_VERSION=$(poetry run pip freeze | grep 'ray==' | sed 's/ray==//')" >> $GITHUB_ENV
- name: Set image version
run: echo "IMAGE_VERSION=${{ env.RAY_ON_GOLEM_VERSION }}-py${{ inputs.IMAGE_PYTHON_VERSION }}-ray${{ env.RAY_VERSION }}" >> $GITHUB_ENV
- name: Build DEV cluster config file
run: poetry run poe dev_yaml
if: ${{ inputs.IS_TEST_BUILD }}
- name: Get DEV YAML image tag
run: echo "YAML_IMAGE_TAG=$(poetry run yaml-get -p provider.parameters.node_config.demand.image_tag golem-cluster.dev.yaml)" >> $GITHUB_ENV
if: ${{ inputs.IS_TEST_BUILD }}
- name: Get Production YAML image tag
run: echo "YAML_IMAGE_TAG=$(poetry run yaml-get -p provider.parameters.node_config.demand.image_tag golem-cluster.yaml)" >> $GITHUB_ENV
if: ${{ ! inputs.IS_TEST_BUILD }}
- name: Set YAML image tag
run: echo "::set-output name=tag::${{ env.YAML_IMAGE_TAG }}"
id: yaml_image_tag
- name: Set pushed image tag
run: echo "::set-output name=tag::${{ inputs.REGISTRY_REPOSITORY }}:${{ env.IMAGE_VERSION }}"
id: pushed_image_tag
- name: Test
run: echo ${{ steps.pushed_image_tag.outputs.tag }} VS ${{ steps.yaml_image_tag.outputs.tag }}
- name: Fail on YAML tag mismatch
run: exit 1
if:
${{ steps.yaml_image_tag.outputs.tag != steps.pushed_image_tag.outputs.tag }}
- name: Build the image
run: docker build -t ray-on-golem:${{ env.IMAGE_VERSION }} --build-arg="PYTHON_VERSION=${{ inputs.IMAGE_PYTHON_VERSION }}" .
- name: Convert the image
run: poetry run gvmkit-build ray-on-golem:${{ env.IMAGE_VERSION }}
- name: Push the image
run: REGISTRY_USER=${{ secrets.REGISTRY_USER }} REGISTRY_TOKEN=${{ secrets.REGISTRY_TOKEN }} poetry run gvmkit-build ray-on-golem:${{ env.IMAGE_VERSION }} --push-to ${{ steps.pushed_image_tag.outputs.tag }}