mirror of https://github.com/status-im/consul.git
Merge pull request #7502 from hashicorp/dnephin/fix-cherry-picker-2
ci: Move shebang to first line of cherry pick script
This commit is contained in:
commit
fe706a54b0
|
@ -1,10 +1,13 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
# This script is meant to run on every new commit to master in CircleCI. If the commit comes from a PR, it will
|
# This script is meant to run on every new commit to master in CircleCI. If the commit comes from a PR, it will
|
||||||
# check the PR associated with the commit for labels. If the label matches `docs*` it will be cherry-picked
|
# check the PR associated with the commit for labels. If the label matches `docs*` it will be cherry-picked
|
||||||
# to stable-website. If the label matches `backport/*`, it will be cherry-picked to the appropriate `release/*`
|
# to stable-website. If the label matches `backport/*`, it will be cherry-picked to the appropriate `release/*`
|
||||||
# branch.
|
# branch.
|
||||||
|
|
||||||
# Requires $CIRCLE_PROJECT_USERNAME, $CIRCLE_PROJECT_REPONAME, and $CIRCLE_SHA1 from CircleCI
|
# Requires $CIRCLE_PROJECT_USERNAME, $CIRCLE_PROJECT_REPONAME, and $CIRCLE_SHA1 from CircleCI
|
||||||
#!/bin/bash
|
|
||||||
|
set -e -o pipefail
|
||||||
|
|
||||||
# colorized status prompt
|
# colorized status prompt
|
||||||
function status {
|
function status {
|
||||||
|
@ -21,13 +24,13 @@ function cherry_pick_with_slack_notification {
|
||||||
# $2 - commit to cherry-pick
|
# $2 - commit to cherry-pick
|
||||||
# $3 - url to PR of commit
|
# $3 - url to PR of commit
|
||||||
|
|
||||||
local branch=$1
|
local branch="$1"
|
||||||
local commit=$2
|
local commit="$2"
|
||||||
local pr_url=$3
|
local pr_url="$3"
|
||||||
|
|
||||||
git checkout $branch || exit 1
|
git checkout "$branch" || exit 1
|
||||||
# If git cherry-pick fails, we send a failure notification
|
# If git cherry-pick fails, we send a failure notification
|
||||||
if ! git cherry-pick --mainline 1 $commit; then
|
if ! git cherry-pick --mainline 1 "$commit"; then
|
||||||
status "🍒❌ Cherry pick of commit ${commit:0:7} from $pr_url onto $branch failed!"
|
status "🍒❌ Cherry pick of commit ${commit:0:7} from $pr_url onto $branch failed!"
|
||||||
curl -X POST -H 'Content-type: application/json' \
|
curl -X POST -H 'Content-type: application/json' \
|
||||||
--data \
|
--data \
|
||||||
|
@ -41,7 +44,7 @@ function cherry_pick_with_slack_notification {
|
||||||
\"color\": \"danger\" \
|
\"color\": \"danger\" \
|
||||||
} \
|
} \
|
||||||
] \
|
] \
|
||||||
}" ${CONSUL_SLACK_WEBHOOK_URL}
|
}" "${CONSUL_SLACK_WEBHOOK_URL}"
|
||||||
git status
|
git status
|
||||||
exit 1
|
exit 1
|
||||||
# Else we send a success notification
|
# Else we send a success notification
|
||||||
|
@ -59,7 +62,7 @@ function cherry_pick_with_slack_notification {
|
||||||
\"color\": \"good\" \
|
\"color\": \"good\" \
|
||||||
} \
|
} \
|
||||||
] \
|
] \
|
||||||
}" ${CONSUL_SLACK_WEBHOOK_URL}
|
}" "${CONSUL_SLACK_WEBHOOK_URL}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,13 +102,13 @@ for label in $labels; do
|
||||||
if [[ $label == docs-cherrypick ]]; then
|
if [[ $label == docs-cherrypick ]]; then
|
||||||
status "backporting to stable-website"
|
status "backporting to stable-website"
|
||||||
branch="stable-website"
|
branch="stable-website"
|
||||||
cherry_pick_with_slack_notification $branch $CIRCLE_SHA1 $pr_url
|
cherry_pick_with_slack_notification "$branch" "$CIRCLE_SHA1" "$pr_url"
|
||||||
git push origin stable-website
|
git push origin stable-website
|
||||||
# else if the label matches backport/*, it will attempt to cherry-pick to the release branch
|
# else if the label matches backport/*, it will attempt to cherry-pick to the release branch
|
||||||
elif [[ $label =~ backport/* ]]; then
|
elif [[ $label =~ backport/* ]]; then
|
||||||
status "backporting to $label"
|
status "backporting to $label"
|
||||||
branch="${label/backport/release}.x"
|
branch="${label/backport/release}.x"
|
||||||
cherry_pick_with_slack_notification $branch $CIRCLE_SHA1 $pr_url
|
cherry_pick_with_slack_notification "$branch" "$CIRCLE_SHA1" "$pr_url"
|
||||||
git push origin $branch
|
git push origin "$branch"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in New Issue