|
| 1 | +--- |
| 2 | +name: Run OpenShift Preflight |
| 3 | +description: | |
| 4 | + This action downloads the OpenShift preflight tool, runs it, and then reports |
| 5 | + if the check passed. |
| 6 | +inputs: |
| 7 | + preflight-version: |
| 8 | + default: latest |
| 9 | + description: The version of the OpenShift preflight tool. |
| 10 | + image-index-uri: |
| 11 | + description: | |
| 12 | + The image index URI (eg. oci.stackable.tech/sdp/kafka:3.4.1-stackable0.0.0-dev) of the image |
| 13 | + to be checked. |
| 14 | + image-architecture: |
| 15 | + description: The image architecture to be checked. |
| 16 | +runs: |
| 17 | + using: composite |
| 18 | + steps: |
| 19 | + - name: Download the OpenShift preflight tool |
| 20 | + env: |
| 21 | + PREFLIGHT_VERSION: ${{ inputs.preflight-version }} |
| 22 | + GITHUB_DEBUG: ${{ runner.debug }} |
| 23 | + shell: bash |
| 24 | + run: | |
| 25 | + set -euo pipefail |
| 26 | + [ -n "$GITHUB_DEBUG" ] && set -x |
| 27 | +
|
| 28 | + ARCH=$("$GITHUB_ACTION_PATH/../.scripts/actions/get_architecture.sh") |
| 29 | + SYSTEM=$("$GITHUB_ACTION_PATH/../.scripts/actions/get_platform.sh") |
| 30 | +
|
| 31 | + if [ "$PREFLIGHT_VERSION" == "latest" ]; then |
| 32 | + curl -fsSL -o /tmp/openshift-preflight "https://github.com/redhat-openshift-ecosystem/openshift-preflight/releases/latest/download/preflight-${SYSTEM}-${ARCH}" |
| 33 | + else |
| 34 | + curl -fsSL -o /tmp/openshift-preflight "https://github.com/redhat-openshift-ecosystem/openshift-preflight/releases/download/${PREFLIGHT_VERSION}/preflight-${SYSTEM}-${ARCH}" |
| 35 | + fi |
| 36 | +
|
| 37 | + sudo install -m 755 -t /usr/local/bin /tmp/openshift-preflight |
| 38 | +
|
| 39 | + - name: Check Container Image |
| 40 | + env: |
| 41 | + IMAGE_ARCHITECTURE: ${{ inputs.image-architecture }} |
| 42 | + IMAGE_INDEX_URI: ${{ inputs.image-index-uri }} |
| 43 | + GITHUB_DEBUG: ${{ runner.debug }} |
| 44 | + shell: bash |
| 45 | + run: | |
| 46 | + set -euo pipefail |
| 47 | + [ -n "$GITHUB_DEBUG" ] && set -x |
| 48 | +
|
| 49 | + openshift-preflight check container "$IMAGE_INDEX_URI" --platform "linux/$IMAGE_ARCHITECTURE" > preflight.out |
| 50 | +
|
| 51 | + - name: Report Result |
| 52 | + env: |
| 53 | + GITHUB_DEBUG: ${{ runner.debug }} |
| 54 | + shell: bash |
| 55 | + run: | |
| 56 | + set -euo pipefail |
| 57 | + [ -n "$GITHUB_DEBUG" ] && set -x |
| 58 | +
|
| 59 | + if [ "$(jq -r .passed < preflight.out)" == true ]; then |
| 60 | + echo "Checks Passed" |
| 61 | + exit 0 |
| 62 | + else |
| 63 | + echo "Checks failed" |
| 64 | + cat preflight.out |
| 65 | + exit 1 |
| 66 | + fi |
0 commit comments