diff --git a/.github/workflows/promote-to-release-channel.yaml b/.github/workflows/promote-to-release-channel.yaml new file mode 100644 index 000000000..fad0916a8 --- /dev/null +++ b/.github/workflows/promote-to-release-channel.yaml @@ -0,0 +1,93 @@ +name: "Promote serverless to release channel" + +on: + workflow_dispatch: + inputs: + serverless_tag: + description: 'Serverless tag to promote (`x.x.x`)' + default: "" + required: true + channel: + type: choice + description: 'Module channel' + options: + - fast + - regular + - experimental + - dev + required: true + +env: + MODULE_VERSION: ${{ github.event.inputs.serverless_tag }} + CHANNEL: ${{ github.event.inputs.channel }} + # needed by gh cli for GitHub enterprise + GH_ENTERPRISE_TOKEN: ${{ secrets.BOT_TOKEN }} + BOT_USERNAME: kyma-otter-serviceuser + BOT_EMAIL: dl_545734d8fd84a02c39000002@global.corp.sap + GH_TOOLS_REPO_URL: ${{ secrets.GH_TOOLS_REPO_URL }} + +jobs: + + promote-serverless: + name: Get, render and push serverless assets + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.event.inputs.serverless_tag }} + + - name: Download release assets + run: | + gh release download ${{ github.event.inputs.serverless_tag}} --pattern '*.yaml' + + - name: Render module-config + env: + CHANNEL: ${{ github.event.inputs.channel }} + MODULE_VERSION: ${{ github.event.inputs.serverless_tag }} + run: | + make -C hack module-config + echo "==== module-config ===" + cat module-config.yaml + + - name: Set up module-manifests repo + run: | + git config --global user.email "${BOT_EMAIL}" + git config --global user.name "${BOT_USERNAME}" + git clone "https://${BOT_USERNAME}:${GH_ENTERPRISE_TOKEN}@${GH_TOOLS_REPO_URL}/${BOT_USERNAME}/module-manifests.git" + git -C module-manifests remote add upstream "https://${BOT_USERNAME}:${GH_ENTERPRISE_TOKEN}@${GH_TOOLS_REPO_URL}/kyma/module-manifests.git" + + - name: Commit manifest + working-directory: module-manifests + run: | + git fetch upstream + git checkout -B "${MODULE_VERSION}-${CHANNEL}" upstream/main + + mkdir -p modules/serverless/${CHANNEL} + cp ../serverless-operator.yaml modules/serverless/${CHANNEL}/serverless-operator.yaml + cp ../default-serverless-cr.yaml modules/serverless/${CHANNEL}/default-serverless-cr.yaml + cp ../module-config.yaml modules/serverless/${CHANNEL}/module-config.yaml + + + + git add . + git commit -m "promote serverless ${MODULE_VERSION} to ${CHANNEL} channel" + git push origin "${MODULE_VERSION}-${CHANNEL}" -f + + - name: Create PullRequest to module-manifests + working-directory: module-manifests + run: | + prs=$(gh pr list -R "https://${GH_TOOLS_REPO_URL}/kyma/module-manifests" -A "${BOT_USERNAME}" --state open --json headRefName) + + if echo $prs | jq -e ".[] | select(.headRefName==\"${MODULE_VERSION}-${CHANNEL}\")"; then + echo "opened PR already exists, no need to create new one, PR will be updated by push from previous step" + exit 0 + fi + + gh pr create -B main --fill \ + -H "${BOT_USERNAME}:${MODULE_VERSION}-${CHANNEL}" \ + -R "https://${GH_TOOLS_REPO_URL}/kyma/module-manifests/" \ + --title "Promote Serverless ${MODULE_VERSION} to ${CHANNEL} channel" \ + --body "https://github.com/kyma-project/serverless/actions/${{github.run_id}}" \ No newline at end of file diff --git a/hack/Makefile b/hack/Makefile index 8bf0b4382..ac308bfbd 100644 --- a/hack/Makefile +++ b/hack/Makefile @@ -28,3 +28,9 @@ upgrade-test: ## Installs Serverless from latest, upgrades to version specified make -C ${PROJECT_ROOT} install-serverless-latest-release install-serverless-custom-operator make integration-test make -C ${PROJECT_ROOT} remove-serverless + +##@ Actions +.PHONY: module-config +module-config: + yq ".channel = \"${CHANNEL}\" | .version = \"${MODULE_VERSION}\""\ + module-config-template.yaml > module-config.yaml \ No newline at end of file diff --git a/module-config-template.yaml b/module-config-template.yaml index 73a7a3180..405c1b965 100644 --- a/module-config-template.yaml +++ b/module-config-template.yaml @@ -1,4 +1,4 @@ -name: {{.Name}} +name: kyma-project.io/module/serverless channel: {{.Channel}} version: {{.Version}} defaultCR: config/samples/default-serverless-cr.yaml