Skip to content

Commit

Permalink
GHA: remove GITHUB_WORKSPACE when workflow fails due to merge conflict
Browse files Browse the repository at this point in the history
Is it to remove a GITHUB_WORKSPACE directory for self-hosted runners
when a workflow fails due to the merge conflict. This will prevent
the subsequent workflows from getting stuck in the same situation.

Fixes: #8600

Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com>
  • Loading branch information
BbolroC committed Dec 7, 2023
1 parent c14e309 commit f084780
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/git-helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,17 @@ function rebase_atop_of_the_latest_target_branch() {
echo "Rebasing atop of the latest ${TARGET_BRANCH}"
# Recover from any previous rebase left halfway
git rebase --abort 2> /dev/null || true
git rebase origin/${TARGET_BRANCH}
if ! git rebase origin/${TARGET_BRANCH}; then
# if GITHUB_WORKSPACE is defined and an architecture is not equal to x86_64
# (mostly self-hosted runners), then remove the repository
if [ -n "${GITHUB_WORKSPACE}" ] && [ "$(uname -m)" != "x86_64" ]; then
echo "Rebase failed, cleaning up a repository for self-hosted runners and exiting"
sudo rm -rf "${GITHUB_WORKSPACE}"
else
echo "Rebase failed, exiting"
fi
exit 1
fi
fi
}

Expand Down

0 comments on commit f084780

Please sign in to comment.