Skip to content

Commit

Permalink
set the right image for the release (#283)
Browse files Browse the repository at this point in the history
* set the right image for the release

At the moment in case of an release the image gets set to a default value of image: op-skr-registry.localhost:8888/unsigned/manager-images/nats-manager:<version> in the nats-manager.yaml due to an unset IMG var. This commit changes that by setting the IMG. Also, the script was made more generic by removing references to nats and instead, pass the string nats as a var from the ghaw.

* fix comment
  • Loading branch information
friedrichwilken authored Jan 10, 2024
1 parent 2b5ab90 commit 9793908
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
23 changes: 12 additions & 11 deletions .github/scripts/render_and_upload_manifests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

# This script will render the latest manifests and it will uploaded them to the release on github.com.

# Error handling
# Error handling.
set -o nounset # treat unset variables as an error and exit immediately.
set -o errexit # exit immediately when a command fails.
set -E # needs to be set if we want the ERR trap
set -o pipefail # prevents errors in a pipeline from being masked

RELEASE_TAG=${1}
GITHUB_TOKEN=${2}
MODULE_NAME=${2}
GITHUB_TOKEN=${3}

# uploadFile uploads the rendered assets to the github release.
uploadFile() {
Expand All @@ -33,17 +34,17 @@ uploadFile() {

# Render the nats-manager.yaml.
echo "RELEASE_TAG: ${RELEASE_TAG}"
MODULE_VERSION=${RELEASE_TAG} make render-manifest
echo "Generated nats-manager.yaml:"
cat nats-manager.yaml
IMG="europe-docker.pkg.dev/kyma-project/prod/${MODULE_NAME}-manager:${RELEASE_TAG}" make render-manifest
echo "Generated ${MODULE_NAME}-manager.yaml:"
cat ${MODULE_NAME}-manager.yaml

# Find the release on github.com via the release tag.
echo -e "\n Updating github release with nats-manager.yaml"
echo -e "\n Updating github release with ${MODULE_NAME}-manager.yaml"
echo "Finding release id for: ${RELEASE_TAG}"
CURL_RESPONSE=$(curl -w "%{http_code}" -sL \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
https://api.github.com/repos/kyma-project/nats-manager/releases)
https://api.github.com/repos/kyma-project/${MODULE_NAME}-manager/releases)
JSON_RESPONSE=$(sed '$ d' <<<"${CURL_RESPONSE}")
HTTP_CODE=$(tail -n1 <<<"${CURL_RESPONSE}")
if [[ "${HTTP_CODE}" != "200" ]]; then
Expand All @@ -58,8 +59,8 @@ if [ -z "${RELEASE_ID}" ]; then
fi

# With the id of the release we can build the URL to upload the assets.
UPLOAD_URL="https://uploads.github.com/repos/kyma-project/nats-manager/releases/${RELEASE_ID}/assets"
UPLOAD_URL="https://uploads.github.com/repos/kyma-project/${MODULE_NAME}-manager/releases/${RELEASE_ID}/assets"

# Finally we will upload the nats-manager.yaml and the default.yaml.
uploadFile "nats-manager.yaml" "${UPLOAD_URL}?name=nats-manager.yaml"
uploadFile "config/samples/default.yaml" "${UPLOAD_URL}?name=nats_default_cr.yaml"
# Finally we will upload the manager.yaml and the default.yaml.
uploadFile "nats-manager.yaml" "${UPLOAD_URL}?name=${MODULE_NAME}-manager.yaml"
uploadFile "config/samples/default.yaml" "${UPLOAD_URL}?name=${MODULE_NAME}-default-cr.yaml"
2 changes: 1 addition & 1 deletion .github/workflows/create-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
env:
KUSTOMIZE_VERSION: "v4.5.6"
run: |
./.github/scripts/render_and_upload_manifests.sh ${{ github.event.inputs.version }} ${{ secrets.GITHUB_TOKEN }}
./.github/scripts/render_and_upload_manifests.sh ${{ github.event.inputs.version }} nats ${{ secrets.GITHUB_TOKEN }}
outputs:
release_id: ${{ steps.create-draft.outputs.release_id }}
Expand Down

0 comments on commit 9793908

Please sign in to comment.