Skip to content

Commit

Permalink
ci: rename release branch (#672)
Browse files Browse the repository at this point in the history
* rename release branch
  • Loading branch information
ypoplavs authored May 16, 2023
1 parent 2d22d89 commit 77c89ad
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/docker-build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Publish Docker image with a commit hash tag
on:
push:
branches:
- release-**
- release/**

jobs:
push_to_registry:
Expand Down Expand Up @@ -46,20 +46,24 @@ 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=$(echo $OLD_BRANCH_NAME | sed 's/[^/]*\///')
# Set up the new branch name
NEW_BRANCH_NAME="release/dashboard/${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
- name: Repository Dispatch
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/docker-build-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,27 +97,29 @@ jobs:
export GH_PUSH_TOKEN
export RELEASE_VERSION
export SERVICE
# 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/dashboard/$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-dashboard
./chart_releaser.sh --helm-chart-folder testkube-$SERVICE
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-dashboard --branch true
./chart_releaser.sh --helm-chart-folder testkube-$SERVICE --branch true
fi
env:
SERVICE: dashboard
GH_PUSH_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
RELEASE_VERSION: ${{ steps.tag.outputs.tag }}

0 comments on commit 77c89ad

Please sign in to comment.