Skip to content

Commit 57f8e9c

Browse files
authored
SLS-1543: Add script to automatically create PR against documentation (#231)
Add functionality to automatically create PRs against Datadog/Documentation when deploying new lambda layers.
1 parent 7fca5df commit 57f8e9c

File tree

3 files changed

+58
-2
lines changed

3 files changed

+58
-2
lines changed

scripts/create_documentation_pr.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
3+
# Unless explicitly stated otherwise all files in this repository are licensed
4+
# under the Apache License Version 2.0.
5+
# This product includes software developed at Datadog (https://www.datadoghq.com/).
6+
# Copyright 2019 Datadog, Inc.
7+
8+
# This script automatically opens a PR to the Documentation repo for lambda layer deploys
9+
10+
GREEN="\033[0;32m"
11+
NC="\033[0;0m"
12+
DOCUMENTATION_REPO_PATH=$HOME/go/src/github.com/DataDog/documentation
13+
DOCUMENTATION_FILE=./layouts/shortcodes/latest-lambda-layer-version.html
14+
15+
function print_color {
16+
printf "$GREEN$1$NC\n"
17+
}
18+
19+
print_color "Creating a Github PR to update documentation"
20+
21+
if [ ! -d $DOCUMENTATION_REPO_PATH ]; then
22+
print_color "Documentation directory does not exist, cloning into $DOCUMENTATION_REPO_PATH"
23+
git clone [email protected]:DataDog/documentation $DOCUMENTATION_REPO_PATH
24+
fi
25+
26+
cd $DOCUMENTATION_REPO_PATH
27+
28+
# Make sure they don't have any local changes
29+
if [ ! -z "$(git status --porcelain)" ]; then
30+
print_color "Documentation directory is dirty -- please stash or save your changes and manually create the PR"
31+
exit 1
32+
fi
33+
34+
print_color "Pulling latest changes from Github"
35+
git checkout master
36+
git pull
37+
38+
print_color "Checking out new branch that has version changes"
39+
git checkout -b $USER/bump-nodejs-layer-version-$VERSION
40+
sed -i '' -e '/.*"node"/{' -e 'n;s/.*/ '"$VERSION"'/' -e '}' $DOCUMENTATION_FILE
41+
git add $DOCUMENTATION_FILE
42+
43+
print_color "Creating commit -- please tap your Yubikey if prompted"
44+
git commit -m "Bump $LAYER layer to version $VERSION"
45+
git push --set-upstream origin $USER/bump-nodejs-layer-version-$VERSION
46+
dd-pr
47+
48+
# Reset documentation repo to clean a state that's tracking master
49+
print_color "Resetting documentation git branch to master"
50+
git checkout -B master origin/master

scripts/publish_prod.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,6 @@ git push origin "refs/tags/v$NEW_VERSION"
8989
echo
9090
echo "Now create a new release with the tag v${NEW_VERSION} created"
9191
echo "https://github.com/DataDog/datadog-lambda-js/releases/new?tag=v$NEW_VERSION&title=v$NEW_VERSION"
92-
echo "Also, remember to update ${HOME}/go/src/github.com/datadog/documentation/layouts/shortcodes/latest-lambda-layer-version.html"
92+
93+
# Open a PR to the documentation repo to automatically bump layer version
94+
VERSION=$VERSION LAYER=datadog-lambda-js ./scripts/create_documentation_pr.sh

scripts/publish_sandbox.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
# Usage: VERSION=5 aws-vault exec sandbox-acccount-admin -- publish_sandbox.sh
3+
# Usage: VERSION=5 aws-vault exec sandbox-account-admin -- publish_sandbox.sh
44
set -e
55

66
if [ -z "$VERSION" ]; then
@@ -12,3 +12,7 @@ fi
1212
./scripts/build_layers.sh
1313
./scripts/sign_layers.sh sandbox
1414
VERSION=$VERSION REGIONS=sa-east-1 ./scripts/publish_layers.sh
15+
16+
# Automatically create PR against github.com/DataDog/documentation
17+
# If you'd like to test, please uncomment the below line
18+
# VERSION=$VERSION LAYER=datadog-lambda-js ./scripts/create_documentation_pr.sh

0 commit comments

Comments
 (0)