-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add scripts/build-push.sh #76
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9482171
feat: add scripts/build-push.sh
e58b450
feat: add workflow to certify image manually
bd4df64
chore: minor updates
726ec2c
chore: test workflow
17ad032
chore: fix ECR credentials
d42cf40
feat: install preflight
5733779
chore: fix preflight installation; remove test workflow
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
name: Manual test run | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
push: | ||
type: choice | ||
description: Push the image to repository | ||
options: | ||
- "true" | ||
- "false" | ||
check: | ||
type: choice | ||
description: Check the image using preflight | ||
options: | ||
- "true" | ||
- "false" | ||
certify: | ||
type: choice | ||
description: Certify the image | ||
options: | ||
- "true" | ||
- "false" | ||
force: | ||
type: choice | ||
description: Perform action even if image already exists | ||
options: | ||
- "false" | ||
- "true" | ||
name: | ||
description: Image name | ||
required: true | ||
type: string | ||
version: | ||
description: Image version | ||
required: true | ||
type: string | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-22.04 | ||
env: | ||
PUSH: "${{ inputs.push }}" | ||
CHECK: "${{ inputs.check }}" | ||
CERTIFY: "${{ inputs.certify }}" | ||
FORCE: "${{ inputs.force }}" | ||
NAME: "${{ inputs.NAME }}" | ||
VERSION: "${{ inputs.VERSION }}" | ||
PYAXIS_API_TOKEN: ${{ secrets.RED_HAT_API_KEY }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Login to Open Source ECR | ||
run: make login | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
- name: Get preflight | ||
run: | | ||
curl -L https://github.com/redhat-openshift-ecosystem/openshift-preflight/releases/download/latest/preflight-linux-amd64 | ||
chmod +x preflight-linux-amd64 | ||
mv preflight-linux-amd64 /usr/local/bin/preflight | ||
- name: Build push | ||
run: | | ||
PYAXIS_API_TOKEN="${PYAXIS_API_TOKEN=}" \ | ||
NAME="${NAME}" \ | ||
VERSION="${VERSION}" \ | ||
CHECK="${CHECK}" \ | ||
PUSH="${PUSH}" \ | ||
FORCE="${FORCE}" \ | ||
CERTIFY="${CERTIFY}" \ | ||
./scripts/build-push.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Manual test run | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-22.04 | ||
env: | ||
PUSH: "true" | ||
CHECK: "true" | ||
CERTIFY: "true" | ||
FORCE: "true" | ||
NAME: opentelemetry-operator | ||
VERSION: "0.95.0" | ||
PYAXIS_API_TOKEN: ${{ secrets.RED_HAT_API_KEY }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Login to Open Source ECR | ||
run: make login | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
- name: Get preflight | ||
run: | | ||
curl -LO https://github.com/redhat-openshift-ecosystem/openshift-preflight/releases/latest/download/preflight-linux-amd64 | ||
chmod +x preflight-linux-amd64 | ||
mv preflight-linux-amd64 /usr/local/bin/preflight | ||
- name: Build push | ||
run: | | ||
PYAXIS_API_TOKEN="${PYAXIS_API_TOKEN=}" \ | ||
NAME="${NAME}" \ | ||
VERSION="${VERSION}" \ | ||
CHECK="${CHECK}" \ | ||
PUSH="${PUSH}" \ | ||
FORCE="${FORCE}" \ | ||
CERTIFY="${CERTIFY}" \ | ||
./scripts/build-push.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
preflight.log | ||
artifacts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
# consts | ||
readonly SUMO_REGISTRY="public.ecr.aws/sumologic/" | ||
|
||
function usage() { | ||
echo "usage: NAME=image name VERSION= PYAXIS_API_TOKEN= ./scripts/build-push.sh | ||
|
||
PYAXIS_API_TOKEN token for Red Hat API | ||
NAME image to build, for example 'opentelemetry-operator' | ||
VERSION version to build from (without prefix), for example 'v0.95.0' | ||
PUSH set to 'true' to push image. Default is 'false' | ||
CHECK set to 'true' to perform preflight check on the image. Default is 'false', requires 'PUSH=true' | ||
CERTIFY set to 'true' to certify image. If 'false', it will use '-dev' suffix for image tag. Default is 'false', requires 'CHECK=true' | ||
FORCE set to 'true' to perform action if image already exist in repository. Default is 'false' | ||
PLATFORM platform to test. Default is 'amd64'" | ||
} | ||
|
||
## Perform image check | ||
function check(){ | ||
echo "Checking image, image: ${IMAGE_NAME}" | ||
make -C "${NAME}" check PLATFORM="${PLATFORM}" IMAGE_NAME="${IMAGE_NAME}" UPSTREAM_VERSION="${VERSION}" | ||
} | ||
|
||
## Perform image submit for certification | ||
function submit(){ | ||
echo "Submitting image for cerification, image: ${IMAGE_NAME}" | ||
## Fetch container project id based on directory(image) name | ||
CONTAINER_PROJECT_ID="$(curl -sH "X-API-KEY: ${PYAXIS_API_TOKEN}" "https://catalog.redhat.com/api/containers/v1/product-listings/id/${OPERATOR_PROJECT_ID}/projects/certification" | jq ".data[] | select(.name == \"${NAME}\")._id" --raw-output)" | ||
## Fetch key for image registry | ||
CONTAINER_REGISTRY_KEY="$(curl -sH "X-API-KEY: ${PYAXIS_API_TOKEN}" "https://catalog.redhat.com/api/containers/v1/projects/certification/id/${CONTAINER_PROJECT_ID}/secrets" | jq ".registry_credentials.password" --raw-output)" | ||
DOCKER_CONFIG_JSON="$(curl -sH "X-API-KEY: ${PYAXIS_API_TOKEN}" "https://catalog.redhat.com/api/containers/v1/projects/certification/id/${CONTAINER_PROJECT_ID}/secrets" | jq ".docker_config_json" --raw-output)" | ||
|
||
CONTAINER_PROJECT_ID=${CONTAINER_PROJECT_ID} \ | ||
CONTAINER_REGISTRY_KEY=${CONTAINER_REGISTRY_KEY} \ | ||
AUTH_CONTENT=${DOCKER_CONFIG_JSON} \ | ||
SUMOLOGIC_IMAGE=${IMAGE_NAME} \ | ||
./scripts/submit_image.sh | ||
} | ||
|
||
# NAME is a directory (image) name, for example `opentelemetry-operator` | ||
readonly NAME="${NAME}" | ||
readonly VERSION="${VERSION}" | ||
# Strip v from version | ||
readonly UPSTREAM_VERSION="${VERSION##[v]}" | ||
readonly CHECK="${CHECK:-true}" | ||
readonly PUSH="${PUSH:-false}" | ||
readonly CERTIFY="${CERTIFY:-false}" | ||
readonly FORCE="${FORCE:-false}" | ||
readonly PYAXIS_API_TOKEN="${PYAXIS_API_TOKEN}" | ||
readonly PLATFORM="${PLATFORM:-amd64}" | ||
DEV_SUFFIX="" | ||
|
||
## Sumo Logic Helm Operator project id | ||
## rel: https://connect.redhat.com/manage/products/6075d88c2b962feb86bea730/overview | ||
readonly OPERATOR_PROJECT_ID=6075d88c2b962feb86bea730 | ||
|
||
if [[ -z "${NAME}" ]]; then | ||
echo 'Missing NAME variable' 2>&1 | ||
usage | ||
exit 1 | ||
fi | ||
|
||
if [[ -z "${VERSION}" ]]; then | ||
echo 'Missing VERSION variable' 2>&1 | ||
usage | ||
exit 1 | ||
fi | ||
|
||
if [[ -z "${PYAXIS_API_TOKEN}" ]]; then | ||
echo 'Missing PYAXIS_API_TOKEN variable' 2>&1 | ||
usage | ||
exit 1 | ||
fi | ||
|
||
if [[ "${CERTIFY}" == "false" ]]; then | ||
DEV_SUFFIX="-dev" | ||
fi | ||
readonly DEV_SUFFIX | ||
|
||
readonly UBI_VERSION="${VERSION}-ubi" | ||
readonly IMAGE_NAME="${SUMO_REGISTRY}${NAME}:${UBI_VERSION}${DEV_SUFFIX}" | ||
|
||
if docker pull "${IMAGE_NAME}" && [[ "${FORCE}" == "false" ]]; then | ||
echo "Image ${IMAGE_NAME} exists, there is no need to push it once again, continue with next image." 2>&1 | ||
exit 0 | ||
fi | ||
|
||
## Image do not exists or we forcefully want to build and push it | ||
|
||
# Build image | ||
make -C "${NAME}" build IMAGE_NAME="${IMAGE_NAME}" UPSTREAM_VERSION="${UPSTREAM_VERSION}" | ||
|
||
# Push image | ||
if [[ "${PUSH}" != "true" ]]; then | ||
exit 0 | ||
fi | ||
|
||
echo "Pushing image, image: ${IMAGE_NAME}" 2>&1 | ||
make -C "${NAME}" push IMAGE_NAME="${IMAGE_NAME}" UPSTREAM_VERSION="${UPSTREAM_VERSION}" | ||
|
||
if [[ "${CHECK}" == "false" ]]; then | ||
exit 0 | ||
fi | ||
check | ||
|
||
if [[ "${CERTIFY}" == "false" ]]; then | ||
exit 0 | ||
fi | ||
|
||
submit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we should check before certify
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the order here matter at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Order is not important, it is only value of variable. I suspect that Dominik changed the order to have logical order of variables.