Skip to content

Commit

Permalink
SLS-1543: Automatically open documentation PR when deploying (#28)
Browse files Browse the repository at this point in the history
* Automatically open documentation PR when deploying

* Remove aws-vault invocation

* Fix comments

* Update publish_sandbox.sh

Comment out PR posting functionality.
  • Loading branch information
IvanTopolcic authored Oct 6, 2021
1 parent be5971f commit 164740e
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 2 deletions.
50 changes: 50 additions & 0 deletions scripts/create_documentation_pr.sh
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 git@github.com: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-$LAYER-version-$VERSION
sed -i '' -e '/.*"extension"/{' -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-$LAYER-version-$VERSION
dd-pr

# 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
5 changes: 4 additions & 1 deletion scripts/publish_prod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,7 @@ echo
echo "IMPORTANT: Please follow the following steps to create release notes:"
echo "1. Manually create a new tag called lambda-extension-${VERSION} in the datadog-agent repository"
echo "2. Create a new GitHub release in the datadog-lambda-extension repository using the tag v${VERSION}, and add release notes"
echo ">>> https://github.com/DataDog/datadog-lambda-extension/releases/new?tag=v${VERSION}&title=v${VERSION}"
echo ">>> https://github.com/DataDog/datadog-lambda-extension/releases/new?tag=v${VERSION}&title=v${VERSION}"

# Open a PR to the documentation repo to automatically bump layer version
VERSION=$VERSION LAYER=datadog-lambda-extension ./scripts/create_documentation_pr.sh
7 changes: 6 additions & 1 deletion scripts/publish_sandbox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2021 Datadog, Inc.

#!/bin/bash
# Usage: VERSION=5 ./scripts/publish_sandbox.sh

set -e

# Move into the root directory
Expand All @@ -14,3 +15,7 @@ cd $SCRIPTS_DIR/..

./scripts/build_binary_and_layer_dockerized.sh
REGIONS=sa-east-1 aws-vault exec sandbox-account-admin -- ./scripts/publish_layers.sh

# Automatically create PR against github.com/DataDog/documentation
# If you'd like to test, please uncomment the below line
# VERSION=$VERSION LAYER=datadog-lambda-extension ./scripts/create_documentation_pr.sh

0 comments on commit 164740e

Please sign in to comment.