Skip to content

Commit

Permalink
Serverless Promote Release Workflow (#871)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cortey authored Apr 10, 2024
1 parent 60095f0 commit 9fe5491
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 1 deletion.
93 changes: 93 additions & 0 deletions .github/workflows/promote-to-release-channel.yaml
Original file line number Diff line number Diff line change
@@ -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: [email protected]
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}}"
6 changes: 6 additions & 0 deletions hack/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion module-config-template.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: {{.Name}}
name: kyma-project.io/module/serverless
channel: {{.Channel}}
version: {{.Version}}
defaultCR: config/samples/default-serverless-cr.yaml
Expand Down

0 comments on commit 9fe5491

Please sign in to comment.