Skip to content

Commit

Permalink
Fix: deal with auto-deleted branches.
Browse files Browse the repository at this point in the history
  • Loading branch information
nastacio committed Mar 8, 2022
1 parent b04e4c7 commit 97ea39d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 24 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/merge-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ jobs:
- uses: actions/checkout@v2

- id: calc
if: github.event.pull_request.merged
name: Determine extent of testing
run: tests/postbuild/calc-settings.sh "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" "${GITHUB_HEAD_REF}" "${GITHUB_BASE_REF}"

- name: Promote release if test passes
if: github.event.pull_request.merged
run: tests/postbuild/promote-release.sh "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" "${GITHUB_HEAD_REF}" "$(cat test-sh-semver.txt)"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35 changes: 11 additions & 24 deletions tests/postbuild/promote-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fi
# Input variables
git_repo=${1}
git_source_branch=${2}
release_delta=${4}
release_delta=${3}


#
Expand All @@ -28,27 +28,6 @@ cleanRun() {
trap cleanRun EXIT


#
# Extracts only the file names containing differences between the source
# and target branches.
#
function extract_branch() {
local result=0

#
# Analyze the differences between branches
# to determine which Cloud Paks to test
git clone "${git_repo}" cloudpak-gitops \
&& cd cloudpak-gitops \
&& git config pull.rebase false \
&& git checkout "${git_source_branch}" \
&& git pull origin "${git_source_branch}" \
|| result=1

return ${result}
}


#
# Determines the new release number and creates a draft release with it.
#
Expand All @@ -59,6 +38,16 @@ function merge_and_promote() {

local result=0

cd "${WORKDIR}" \
&& git clone "${git_repo}" cloudpak-gitops \
&& cd cloudpak-gitops \
|| result=1

if [ ${result} -eq 1 ]; then
echo "ERROR: Unable to clone repository."
return 1
fi

latest_version=$(git tag -l --sort=version:refname "v*" | tail -n 1)
latest_major_version=$(echo "${latest_version//.*/}" | cut -d "v" -f 2)
latest_minor_version=$(echo "${latest_version}" | cut -d "." -f 2)
Expand Down Expand Up @@ -124,8 +113,6 @@ function merge_and_promote() {
WORKDIR=$(mktemp -d) || exit 1
cd "${WORKDIR}"

extract_branch

is_draft=$(gh pr view "${git_source_branch}" --repo "${git_repo}" --json isDraft -t '{{.isDraft}}')
if [ "${is_draft}" == "true" ]; then
echo "Pull request is still a draft. Skipping"
Expand Down

0 comments on commit 97ea39d

Please sign in to comment.