From 054ea0ba6ebffe66f5b6b890d8226624b517ce54 Mon Sep 17 00:00:00 2001 From: labkey-tchad Date: Tue, 10 Mar 2026 09:43:37 -0700 Subject: [PATCH 1/5] Don't use API to check for branch existence --- branch-release/branch_release.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/branch-release/branch_release.sh b/branch-release/branch_release.sh index 343dcba..3819329 100755 --- a/branch-release/branch_release.sh +++ b/branch-release/branch_release.sh @@ -166,7 +166,7 @@ function increment_version() { git config --global user.name "github-actions" git config --global user.email "teamcity@labkey.com" -# Just create release branches if they don't exist +# Just create release branches if they don't exist. Use API to check because branches aren't present in shallow clone. if ! hub api "repos/{owner}/{repo}/branches/${SNAPSHOT_BRANCH}"; then # Check to see if TeamCity tagged the wrong branch AHEAD_DEVELOP="$(hub api "repos/{owner}/{repo}/compare/develop...${GITHUB_SHA}" | grep -oE "${AHEAD_BY_EXP}" | cut -d':' -f 2)" @@ -212,7 +212,10 @@ if ! hub api "repos/{owner}/{repo}/branches/${SNAPSHOT_BRANCH}"; then fi fi -git fetch --unshallow || true +if [ `git rev-parse --is-shallow-repository` = 'true' ] && ! git fetch --unshallow; then + echo "Failed to unshallow reposiotry. Rerun action." >&2 + exit 1 +fi if $SERVER_REPO && [ "$PATCH_NUMBER" == "0" ]; then echo "Create non-SNAPSHOT branch in server repository for '.0' release" @@ -309,7 +312,7 @@ esac if [ -n "${NEXT_RELEASE:-}" ]; then TARGET_BRANCH=release${NEXT_RELEASE}-SNAPSHOT - if hub api "repos/{owner}/{repo}/git/refs/heads/${TARGET_BRANCH}"; then + if git rev-parse --verify --quiet "refs/heads/${TARGET_BRANCH}"; then echo "" echo "Next ESR release '${TARGET_BRANCH}' exist. Merging ${TAG} to it." MERGE_BRANCH="${NEXT_RELEASE}_fb_bot_merge_${RELEASE_NUM}" @@ -326,7 +329,7 @@ if [ -n "${NEXT_RELEASE:-}" ]; then if ! git tag -l | grep "${NEXT_RELEASE}.0" ; then echo "Monthly release ${NEXT_RELEASE}.0 doesn't exist. Check for branch." TARGET_BRANCH=release${NEXT_RELEASE}-SNAPSHOT - if hub api "repos/{owner}/{repo}/git/refs/heads/${TARGET_BRANCH}"; then + if git rev-parse --verify --quiet "refs/heads/${TARGET_BRANCH}"; then # 'SNAPSHOT' branch exists but '.0' release hasn't been created. Merge to it! MERGE_BRANCH="${NEXT_RELEASE}_fb_bot_merge_${RELEASE_NUM}" else @@ -351,7 +354,7 @@ if [ -z "${MERGE_BRANCH:-}" ]; then MERGE_BRANCH=fb_bot_merge_${RELEASE_NUM} fi -if hub api "repos/{owner}/{repo}/git/refs/heads/${MERGE_BRANCH}"; then +if git rev-parse --verify --quiet "refs/heads/${MERGE_BRANCH}"; then RELEASE_DIFF="$(git log --cherry-pick --oneline --no-decorate "origin/${MERGE_BRANCH}..${GITHUB_SHA}" | grep -v -e '^$')" if [ -z "${RELEASE_DIFF:-}" ]; then From f5114a6800f42f87adfcd65c0cd9efff23fda34a Mon Sep 17 00:00:00 2001 From: labkey-tchad Date: Tue, 10 Mar 2026 10:05:49 -0700 Subject: [PATCH 2/5] shellcheck fixes --- branch-release/branch_release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/branch-release/branch_release.sh b/branch-release/branch_release.sh index 3819329..3ee3d00 100755 --- a/branch-release/branch_release.sh +++ b/branch-release/branch_release.sh @@ -212,7 +212,7 @@ if ! hub api "repos/{owner}/{repo}/branches/${SNAPSHOT_BRANCH}"; then fi fi -if [ `git rev-parse --is-shallow-repository` = 'true' ] && ! git fetch --unshallow; then +if [ "$(git rev-parse --is-shallow-repository)" = 'true' ] && ! git fetch --unshallow; then echo "Failed to unshallow reposiotry. Rerun action." >&2 exit 1 fi From 30d05c2a52578f4bd6ff7752bd92a3a99d78e91a Mon Sep 17 00:00:00 2001 From: labkey-tchad Date: Tue, 10 Mar 2026 10:35:14 -0700 Subject: [PATCH 3/5] rev-parse tag also --- branch-release/branch_release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/branch-release/branch_release.sh b/branch-release/branch_release.sh index 3ee3d00..7bc0715 100755 --- a/branch-release/branch_release.sh +++ b/branch-release/branch_release.sh @@ -326,7 +326,7 @@ if [ -n "${NEXT_RELEASE:-}" ]; then # Calculate next monthly release NEXT_RELEASE="$(increment_version "$NEXT_RELEASE")" # Check for '.0' tag - if ! git tag -l | grep "${NEXT_RELEASE}.0" ; then + if ! git rev-parse --verify --quiet "refs/tags/${NEXT_RELEASE}.0" ; then echo "Monthly release ${NEXT_RELEASE}.0 doesn't exist. Check for branch." TARGET_BRANCH=release${NEXT_RELEASE}-SNAPSHOT if git rev-parse --verify --quiet "refs/heads/${TARGET_BRANCH}"; then From 780fa5f6955ccce4d48f84e46abf8f743acab298 Mon Sep 17 00:00:00 2001 From: labkey-tchad Date: Tue, 10 Mar 2026 14:00:11 -0700 Subject: [PATCH 4/5] Fix typo and update actions --- .github/workflows/shellcheck.yml | 2 +- .github/workflows/yamllint.yml | 4 ++-- branch-release/branch_release.sh | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml index 9c47026..0ef1e94 100644 --- a/.github/workflows/shellcheck.yml +++ b/.github/workflows/shellcheck.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Run ShellCheck uses: ludeeus/action-shellcheck@master diff --git a/.github/workflows/yamllint.yml b/.github/workflows/yamllint.yml index 1cea3f2..54dc9fa 100644 --- a/.github/workflows/yamllint.yml +++ b/.github/workflows/yamllint.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest steps: - name: 'Checkout' - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: yaml-lint - uses: ibiqlik/action-yamllint@v1 + uses: ibiqlik/action-yamllint@v3 diff --git a/branch-release/branch_release.sh b/branch-release/branch_release.sh index 7bc0715..6c20df7 100755 --- a/branch-release/branch_release.sh +++ b/branch-release/branch_release.sh @@ -213,7 +213,7 @@ if ! hub api "repos/{owner}/{repo}/branches/${SNAPSHOT_BRANCH}"; then fi if [ "$(git rev-parse --is-shallow-repository)" = 'true' ] && ! git fetch --unshallow; then - echo "Failed to unshallow reposiotry. Rerun action." >&2 + echo "Failed to unshallow repository. Rerun action." >&2 exit 1 fi From 4da96655812cf23ab755821ae3ff37ce673b8f41 Mon Sep 17 00:00:00 2001 From: labkey-tchad Date: Tue, 10 Mar 2026 14:06:31 -0700 Subject: [PATCH 5/5] cleanup --- .../pull_request_template.md | 0 .github/workflows/shellcheck.yml | 6 ++---- .github/workflows/yamllint.yml | 4 +++- branch-release/example.workflow.yml | 2 +- merge-release/example.workflow.yml | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) rename pull_request_template.md => .github/pull_request_template.md (100%) diff --git a/pull_request_template.md b/.github/pull_request_template.md similarity index 100% rename from pull_request_template.md rename to .github/pull_request_template.md diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml index 0ef1e94..c076740 100644 --- a/.github/workflows/shellcheck.yml +++ b/.github/workflows/shellcheck.yml @@ -1,10 +1,8 @@ --- name: 'Run Shellcheck' -on: - push: - branches-ignore: - - 'master' +"on": + - pull_request jobs: shellcheck: diff --git a/.github/workflows/yamllint.yml b/.github/workflows/yamllint.yml index 54dc9fa..2901ce2 100644 --- a/.github/workflows/yamllint.yml +++ b/.github/workflows/yamllint.yml @@ -1,7 +1,9 @@ --- name: 'Yamllint GitHub Actions' -on: + +"on": - pull_request + jobs: yamllint: name: 'Yamllint' diff --git a/branch-release/example.workflow.yml b/branch-release/example.workflow.yml index 849a88f..0ca1fda 100644 --- a/branch-release/example.workflow.yml +++ b/branch-release/example.workflow.yml @@ -15,7 +15,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Create branches and PRs uses: labkey-tchad/gitHubActions/branch-release@develop diff --git a/merge-release/example.workflow.yml b/merge-release/example.workflow.yml index f2ca494..36bc395 100644 --- a/merge-release/example.workflow.yml +++ b/merge-release/example.workflow.yml @@ -17,7 +17,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Merge PR uses: labkey-tchad/gitHubActions/merge-release@develop