generated from kyma-project/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Serverless Promote Release Workflow (#871)
- Loading branch information
Showing
3 changed files
with
100 additions
and
1 deletion.
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
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}}" |
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