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 9c47026..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: @@ -12,7 +10,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..2901ce2 100644 --- a/.github/workflows/yamllint.yml +++ b/.github/workflows/yamllint.yml @@ -1,14 +1,16 @@ --- name: 'Yamllint GitHub Actions' -on: + +"on": - pull_request + jobs: yamllint: name: 'Yamllint' 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 343dcba..6c20df7 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 repository. 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}" @@ -323,10 +326,10 @@ 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 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 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