Skip to content

Commit

Permalink
ci: check for existing pull request before auto build-push-pr
Browse files Browse the repository at this point in the history
Signed-off-by: Jérôme Jutteau <jerome.jutteau@outscale.com>
  • Loading branch information
jerome-jutteau committed Jan 14, 2021
1 parent d6ba26b commit 5f13c0e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
24 changes: 24 additions & 0 deletions .github/scripts/release-check-duplicate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/env bash
set -e

root=$(cd "$(dirname $0)/../.." && pwd)
# build new version number
local_sdk_version=$(cat $root/sdk_version)
local_sdk_version_major=$(echo $local_sdk_version | cut -d '.' -f 1)
local_sdk_version_minor=$(echo $local_sdk_version | cut -d '.' -f 2)
new_sdk_version_minor=$(( local_sdk_version_minor + 1 ))
new_sdk_version="$local_sdk_version_major.$new_sdk_version_minor.0"

branch_name="autobuild-$new_sdk_version"

if [ -z "$GH_TOKEN" ]; then
echo "GH_TOKEN is missing, abort."
exit 1
fi

result=$(curl -s -u LolUserName:$GH_TOKEN "https://api.github.com/repos/outscale/osc-sdk-go/pulls" | jq ".[] | select(.title == \"$new_sdk_version version\") | .title")

if [ ! -z "$result" ]; then
echo "Pull request seems to alread exist, abort."
exit 1
fi
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,17 @@ gofmt:
# Used by bot to auto-release
# GH_TOKEN and SSH_PRIVATE_KEY are needed
.PHONY: auto-release
auto-release: osc-api-check release-build release-push release-pr
auto-release: osc-api-check release-check-duplicate release-build release-push release-pr
@echo OK

.PHONY: osc-api-check
osc-api-check:
bash .github/scripts/osc-api-check.sh

.PHONY: release-check-duplicate
release-check-duplicate:
bash .github/scripts/release-check-duplicate.sh

.PHONY: release-build
release-build:
bash .github/scripts/release-build.sh
Expand Down

0 comments on commit 5f13c0e

Please sign in to comment.