-
Notifications
You must be signed in to change notification settings - Fork 270
65 lines (55 loc) · 2.43 KB
/
build-s2i-python-kopf-pr.yaml
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
---
name: build-s2i-python-kopf-pr
on:
pull_request:
paths:
- build-s2i-python-kopf/**
- .github/workflows/build-s2i-python-kopf-pr.yaml
# Declare default permissions as read only.
permissions: read-all
jobs:
test:
env:
CONTEXT_DIR: build-s2i-python-kopf
IMAGE_NAME: python-kopf-s2i
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
- name: Check and verify version.json
id: check_version
uses: redhat-cop/github-actions/get-image-version@e4729075dcd3f34946b80df6b1bfb952b9fee166 # v4
with:
IMAGE_CONTEXT_DIR: ${{ env.CONTEXT_DIR }}
- name: Update Dockerfile version
run: |
sed -i -e "s/^FROM .*/FROM ${IMAGE_NAME}:${{ steps.check_version.outputs.VERSION }}/" ${CONTEXT_DIR}/examples/kopf-simple/Dockerfile
- name: Build s2i image
uses: redhat-actions/buildah-build@7a95fa7ee0f02d552a32753e7414641a04307056 # v2
with:
context: ${{ env.CONTEXT_DIR }}
dockerfiles: |
./${{ env.CONTEXT_DIR }}/Dockerfile
image: ${{ env.IMAGE_NAME }}
oci: true
tags: ${{ steps.check_version.outputs.VERSION }}
- name: Build kopf-simple example from s2i image
uses: redhat-actions/buildah-build@7a95fa7ee0f02d552a32753e7414641a04307056 # v2
with:
context: ${{ env.CONTEXT_DIR }}/examples/kopf-simple
dockerfiles: |
./${{ env.CONTEXT_DIR }}/examples/kopf-simple
image: ${{ env.IMAGE_NAME }}-example
oci: true
tags: ${{ steps.check_version.outputs.VERSION }}
- name: Test image
run: |
EXAMPLE_IMAGE="${IMAGE_NAME}-example:${{ steps.check_version.outputs.VERSION }}"
echo "Checking kopf version..."
KOPF_VERSION="$(podman run --entrypoint '/bin/sh' $EXAMPLE_IMAGE -c 'kopf --version')"
if [[ "$KOPF_VERSION" != 'kopf, version ${{ steps.check_version.outputs.MINOR_VERSION }}' ]]; then
echo "$KOPF_VERSION not expected ${{ steps.check_version.outputs.MINOR_VERSION }}"
fi
echo "Checking example operator.py..."
podman run --entrypoint '/bin/sh' $EXAMPLE_IMAGE -c 'python3 -m py_compile /opt/app-root/operator/operator.py'
echo "Check example requirements were installed..."
podman run --entrypoint '/bin/sh' $EXAMPLE_IMAGE -c 'python3 -c "import yaml"'