From 1f27286d9d0a92ba9f77674fb77ec78e5be7d032 Mon Sep 17 00:00:00 2001 From: Carl Menezes Date: Thu, 10 Aug 2023 11:24:55 +1200 Subject: [PATCH] Abort if a release for the same version is pending --- .github/scripts/check-pending-release.sh | 17 +++++++++++++++++ .github/scripts/push-docs-pr.sh | 5 ----- .github/workflows/publish-docs.yaml | 4 ++++ 3 files changed, 21 insertions(+), 5 deletions(-) create mode 100755 .github/scripts/check-pending-release.sh diff --git a/.github/scripts/check-pending-release.sh b/.github/scripts/check-pending-release.sh new file mode 100755 index 0000000000..d369f6b0d4 --- /dev/null +++ b/.github/scripts/check-pending-release.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +set -e +set -x + +VERSION=$(cat package.json | jq -r '.version') +CLONE_DIR="./imx-docs" +INPUT_DESTINATION_HEAD_BRANCH="ts-immutable-sdk-docs-$VERSION" + +cd "$CLONE_DIR" +PENDING_RELEASE=$(git ls-remote --heads origin refs/heads/$INPUT_DESTINATION_HEAD_BRANCH) +if [ -n "$PENDING_RELEASE" ]; then + echo "There is already a pending release for v$VERSION" + echo "$INPUT_DESTINATION_HEAD_BRANCH already exists." + exit 1 +fi + diff --git a/.github/scripts/push-docs-pr.sh b/.github/scripts/push-docs-pr.sh index 7d590eadbf..d904ee3703 100755 --- a/.github/scripts/push-docs-pr.sh +++ b/.github/scripts/push-docs-pr.sh @@ -17,11 +17,6 @@ else PULL_REQUEST_REVIEWERS='-r '$INPUT_PULL_REQUEST_REVIEWERS fi -# echo "CLONE_DIR: $CLONE_DIR" -# echo "Cloning destination git repository" -# # git clone "https://github.com/$INPUT_DESTINATION_REPO.git" "$CLONE_DIR" -# git clone "https://oauth2:$GITHUB_TOKEN@github.com/$INPUT_DESTINATION_REPO.git" "$CLONE_DIR" - echo "Copying contents to git repo" mkdir -p $INPUT_DESTINATION_FOLDER diff --git a/.github/workflows/publish-docs.yaml b/.github/workflows/publish-docs.yaml index 1923f9657b..7d7ff6d1dc 100644 --- a/.github/workflows/publish-docs.yaml +++ b/.github/workflows/publish-docs.yaml @@ -23,6 +23,10 @@ jobs: path: imx-docs ref: main + - name: Pending release check + run: ./.github/scripts/check-pending-release.sh + shell: bash + - name: Setup Github run: | git config --global user.name "${GITHUB_ACTOR}"