Skip to content

promote to release channel #20

promote to release channel

promote to release channel #20

name: promote 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.GH_BOT_TOKEN }}
BOT_USERNAME: kyma-otter-serviceuser
BOT_EMAIL: [email protected]
GH_TOOLS_REPO_URL: ${{ secrets.GH_TOOLS_REPO_URL }}
SERVERLESS_REPO_URL: ${{ secrets.SERVERLESS_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
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release download ${{ github.event.inputs.serverless_tag}} -R "${SERVERLESS_REPO_URL}" --pattern '*.yaml'
- name: Render module-config
env:
CHANNEL: ${{ github.event.inputs.channel }}
MODULE_VERSION: ${{ github.event.inputs.serverless_tag }}
run: |
make 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}}"