Skip to content

Commit 8165858

Browse files
authored
feat: Add run-openshift-preflight action (#71)
1 parent 7279ffd commit 8165858

File tree

3 files changed

+91
-0
lines changed

3 files changed

+91
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ particular step in a workflow.
2626
- [publish-image](./publish-image/README.md)
2727
- [publish-index-manifest](./publish-index-manifest/README.md)
2828
- [run-integration-test](./run-integration-test/README.md)
29+
- [run-openshift-preflight](./run-openshift-preflight/README.md)
2930
- [run-pre-commit](./run-pre-commit/README.md)
3031
- [send-slack-notification](./send-slack-notification/README.md)
3132
- [setup-k8s-tools](./setup-k8s-tools/README.md)

run-openshift-preflight/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# `run-openshift-preflight`
2+
3+
> Manifest: [run-openshift-preflight/action.yml][run-openshift-preflight]
4+
5+
This action downloads the OpenShift preflight tool, runs it, and then reports if the checks passed.
6+
7+
## Inputs and Outputs
8+
9+
> [!TIP]
10+
> For descriptions of the inputs and outputs, see the complete [run-openshift-preflight] action.
11+
12+
### Inputs
13+
14+
| Input | Required (Default) | Description |
15+
| -------------------- | ------------------ | -------------------------------------------- |
16+
| `image-index-uri` | Yes | The image index URI (eg. oci.stackable.tech/sdp/kafka:3.4.1-stackable0.0.0-dev) of the image to be checked. |
17+
| `image-architecture` | Yes | The image architecture to be checked. |
18+
| `preflight-version` | No (`latest`) | The version of the OpenShift preflight tool. |
19+
20+
### Outputs
21+
22+
None.
23+
24+
[run-openshift-preflight]: ./action.yaml

run-openshift-preflight/action.yaml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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

Comments
 (0)