-
Notifications
You must be signed in to change notification settings - Fork 36
SLS-1543: Add script to automatically create PR against documentation #231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
IvanTopolcic
merged 6 commits into
main
from
ivan.topolcic/automatically-create-documentation-pr
Oct 6, 2021
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f2d94ad
Add script to automatically create PR against documentation
IvanTopolcic a32a284
Make script executable
IvanTopolcic 9d83e77
Change documentation variable from python to node
IvanTopolcic fb28814
Update comments
IvanTopolcic a72f94c
Update PR comment
IvanTopolcic 4e85929
Merge branch 'main' into ivan.topolcic/automatically-create-documenta…
IvanTopolcic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,50 @@ | ||
#!/bin/bash | ||
|
||
# Unless explicitly stated otherwise all files in this repository are licensed | ||
# under the Apache License Version 2.0. | ||
# This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
# Copyright 2019 Datadog, Inc. | ||
|
||
# This script automatically opens a PR to the Documentation repo for lambda layer deploys | ||
|
||
GREEN="\033[0;32m" | ||
NC="\033[0;0m" | ||
DOCUMENTATION_REPO_PATH=$HOME/go/src/github.com/DataDog/documentation | ||
DOCUMENTATION_FILE=./layouts/shortcodes/latest-lambda-layer-version.html | ||
|
||
function print_color { | ||
printf "$GREEN$1$NC\n" | ||
} | ||
|
||
print_color "Creating a Github PR to update documentation" | ||
|
||
if [ ! -d $DOCUMENTATION_REPO_PATH ]; then | ||
print_color "Documentation directory does not exist, cloning into $DOCUMENTATION_REPO_PATH" | ||
git clone [email protected]:DataDog/documentation $DOCUMENTATION_REPO_PATH | ||
fi | ||
|
||
cd $DOCUMENTATION_REPO_PATH | ||
|
||
# Make sure they don't have any local changes | ||
if [ ! -z "$(git status --porcelain)" ]; then | ||
print_color "Documentation directory is dirty -- please stash or save your changes and manually create the PR" | ||
exit 1 | ||
fi | ||
|
||
print_color "Pulling latest changes from Github" | ||
git checkout master | ||
git pull | ||
|
||
print_color "Checking out new branch that has version changes" | ||
git checkout -b $USER/bump-nodejs-layer-version-$VERSION | ||
sed -i '' -e '/.*"node"/{' -e 'n;s/.*/ '"$VERSION"'/' -e '}' $DOCUMENTATION_FILE | ||
git add $DOCUMENTATION_FILE | ||
|
||
print_color "Creating commit -- please tap your Yubikey if prompted" | ||
git commit -m "Bump $LAYER layer to version $VERSION" | ||
git push --set-upstream origin $USER/bump-nodejs-layer-version-$VERSION | ||
IvanTopolcic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
dd-pr | ||
IvanTopolcic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# Reset documentation repo to clean a state that's tracking master | ||
print_color "Resetting documentation git branch to master" | ||
git checkout -B master origin/master |
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.