<commit_before>#!/bin/bash

set -o errexit -o nounset

SOURCE_BRANCH="master"
TARGET_BRANCH="gh-pages"
BUILD_DIR="docs"

if [ "$GITHUB_BRANCH" != "$SOURCE_BRANCH" ]; then
    echo "Non-$SOURCE_BRANCH branch build; skipping deployment."
    exit 0
fi

SHA=`git rev-parse --short HEAD`
GITHUB_PROJECT=$(echo $GITHUB_BASE_REPO_URL | sed 's/^https:\/\/github.com\///' | sed 's/.git$//')
SECRETS_URL="taskcluster/secrets/v1/secret/repo:github.com/$GITHUB_PROJECT"

echo "Using project: $GITHUB_PROJECT"
echo "Using secrets: $SECRETS_URL"

mkdir ~/.ssh
curl "${SECRETS_URL}" | python -c 'import json, sys; a = json.load(sys.stdin); print a["secret"]["githubPubKey"]' >> ~/.ssh/known_hosts

BASE64_DEPLOY_KEY=$(curl ${SECRETS_URL} | python -c 'import json, sys; a = json.load(sys.stdin); print a["secret"]["base64DeployKey"]')
echo "$BASE64_DEPLOY_KEY" | base64 -d > /deploy_key
chmod 600 /deploy_key
eval `ssh-agent -s`
ssh-add /deploy_key

cd $BUILD_DIR
git init
git config user.name "Taskcluster Github"
git config user.email "<EMAIL>"

git remote add upstream "<EMAIL>:$GITHUB_PROJECT.git"
git fetch upstream
git reset "upstream/$TARGET_BRANCH"

touch .

git add -A .
git commit -m "Rebuilding $TARGET_BRANCH from $SHA"
git push -q upstream "HEAD:$TARGET_BRANCH"<commit_msg>deploy with --allow-empty, in case nothing changes<commit_after>#!/bin/bash

set -o errexit -o nounset

SOURCE_BRANCH="master"
TARGET_BRANCH="gh-pages"
BUILD_DIR="docs"

if [ "$GITHUB_BRANCH" != "$SOURCE_BRANCH" ]; then
    echo "Non-$SOURCE_BRANCH branch build; skipping deployment."
    exit 0
fi

SHA=`git rev-parse --short HEAD`
GITHUB_PROJECT=$(echo $GITHUB_BASE_REPO_URL | sed 's/^https:\/\/github.com\///' | sed 's/.git$//')
SECRETS_URL="taskcluster/secrets/v1/secret/repo:github.com/$GITHUB_PROJECT"

echo "Using project: $GITHUB_PROJECT"
echo "Using secrets: $SECRETS_URL"

mkdir ~/.ssh
curl "${SECRETS_URL}" | python -c 'import json, sys; a = json.load(sys.stdin); print a["secret"]["githubPubKey"]' >> ~/.ssh/known_hosts

BASE64_DEPLOY_KEY=$(curl ${SECRETS_URL} | python -c 'import json, sys; a = json.load(sys.stdin); print a["secret"]["base64DeployKey"]')
echo "$BASE64_DEPLOY_KEY" | base64 -d > /deploy_key
chmod 600 /deploy_key
eval `ssh-agent -s`
ssh-add /deploy_key

cd $BUILD_DIR
git init
git config user.name "Taskcluster Github"
git config user.email "<EMAIL>"

git remote add upstream "<EMAIL>:$GITHUB_PROJECT.git"
git fetch upstream
git reset "upstream/$TARGET_BRANCH"

touch .

git add -A .
git commit --allow-empty -m "Rebuilding $TARGET_BRANCH from $SHA"
git push -q upstream "HEAD:$TARGET_BRANCH"
{'fraction_non_alphanumeric': 0.1546471268800617, 'fraction_numerical': 0.010026995757809487, 'mean_word_length': 5.032558139534884, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3537448', 'n_tokens_mistral': 1042, 'n_tokens_neox': 984, 'n_words': 244}