-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix workflow for regenerating tutorials when there's an existing PR
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
- Loading branch information
Showing
3 changed files
with
64 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euf -o pipefail | ||
|
||
function usage { | ||
cat <<EOF | ||
Check out the branch for regenerating tutorials. | ||
Usage: | ||
$0 | ||
Examples: | ||
$0 | ||
EOF | ||
} | ||
|
||
if [[ $# -ne 0 ]]; then | ||
usage | ||
exit 1 | ||
fi | ||
|
||
readonly BRANCH="${BRANCH:-update-generated-tutorials}" | ||
|
||
PR_STATUS=$(gh pr view "${BRANCH}" --json state --jq .state || true) | ||
readponly PR_STATUS | ||
|
||
if [[ "${PR_STATUS}" == OPEN ]]; then | ||
gh pr checkout "${BRANCH}" | ||
|
||
if ! git diff --exit-code; then | ||
commit | ||
git push | ||
fi | ||
|
||
exit 0 | ||
fi | ||
|
||
# Remove the remote branch if it exists because there is no PR associated with it. | ||
if git fetch origin "${BRANCH}"; then | ||
git push origin --delete "${BRANCH}" | ||
fi | ||
|
||
git checkout -b "${BRANCH}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters