Skip to content

Commit

Permalink
rename release branch (#3845)
Browse files Browse the repository at this point in the history
  • Loading branch information
ypoplavs authored May 17, 2023
1 parent fed08e5 commit 14d8f0a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/docker-build-api-executors-tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -397,26 +397,27 @@ jobs:
export GH_PUSH_TOKEN
export RELEASE_VERSION
# Check if release branch exists
# Check if release branch exists in helm-charts repository
REPO_OWNER=kubeshop
REPO_NAME=helm-charts
RELEASE_BRANCH_NAME=release-$RELEASE_VERSION
RELEASE_BRANCH_NAME=release/$SERVICE/$RELEASE_VERSION
echo $RELEASE_VERSION
STATUS=$(curl -s -o /dev/null -w '%{http_code}' -H "${AUTH_HEADER}" "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/branches/${RELEASE_BRANCH_NAME}")
if [ "${STATUS}" -eq 404 ]; then
git fetch origin main
git checkout main
cd ./scripts
./chart_releaser.sh --helm-chart-folder testkube-api --testkube-executor true
./chart_releaser.sh --helm-chart-folder testkube-$SERVICE --testkube-executor true
else
git fetch origin "release-$RELEASE_VERSION"
git checkout "release-$RELEASE_VERSION"
git fetch origin "release/$SERVICE/$RELEASE_VERSION"
git checkout "release/$SERVICE/$RELEASE_VERSION"
echo "Switched to release branch"
cd ./scripts
./chart_releaser.sh --helm-chart-folder testkube-api --testkube-executor true --branch true
./chart_releaser.sh --helm-chart-folder testkube-$SERVICE --testkube-executor true --branch true
fi
env:
SERVICE: api
GH_PUSH_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
RELEASE_VERSION: ${{ steps.tag.outputs.tag }}
16 changes: 10 additions & 6 deletions .github/workflows/docker-build-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Docker images build release
on:
push:
branches:
- release-**
- release/**
paths-ignore:
- 'docs/**'

Expand Down Expand Up @@ -390,19 +390,23 @@ jobs:
# Set up variables for repository and branch name
REPO_OWNER=kubeshop
REPO_NAME=helm-charts
BRANCH_NAME=${GITHUB_REF}
OLD_BRANCH_NAME=${GITHUB_REF}
RELEASE_TAG=$(basename "${OLD_BRANCH_NAME}")
# Set up the new branch name
NEW_BRANCH_NAME="refs/heads/release/operator/${RELEASE_TAG}"
# Set up authentication using a personal access token
AUTH_HEADER="Authorization: Bearer ${{ secrets.CI_BOT_TOKEN }}"
# Check if branch already exists
STATUS=$(curl -s -o /dev/null -w '%{http_code}' -H "${AUTH_HEADER}" "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/branches/${BRANCH_NAME}")
STATUS=$(curl -s -o /dev/null -w '%{http_code}' -H "${AUTH_HEADER}" "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/branches/${NEW_BRANCH_NAME}")
# If branch doesn't exist, create it
if [ "${STATUS}" -eq 404 ]; then
curl -X POST -H "${AUTH_HEADER}" -d '{"ref": "'"${BRANCH_NAME}"'","sha": "'"$(curl -s -H "${AUTH_HEADER}" "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/git/refs/heads/main" | jq -r '.object.sha')"'"}' "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/git/refs"
echo "Created branch ${BRANCH_NAME} in ${REPO_OWNER}/${REPO_NAME}"
curl -X POST -H "${AUTH_HEADER}" -d '{"ref": "'"${NEW_BRANCH_NAME}"'","sha": "'"$(curl -s -H "${AUTH_HEADER}" "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/git/refs/heads/main" | jq -r '.object.sha')"'"}' "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/git/refs"
echo "Created branch ${NEW_BRANCH_NAME} in ${REPO_OWNER}/${REPO_NAME}"
else
echo "Branch ${BRANCH_NAME} already exists in ${REPO_OWNER}/${REPO_NAME}"
echo "Branch ${NEW_BRANCH_NAME} already exists in ${REPO_OWNER}/${REPO_NAME}"
fi

0 comments on commit 14d8f0a

Please sign in to comment.