|
| 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 |
0 commit comments