<commit_before>#!/bin/bash

set -exo pipefail

source docker/bin/set_git_env_vars.sh

if [[ "$BRANCH_NAME" != "prod" ]]; then
    # nothing to do if not prod deployment
    exit 0
fi

CONTAINER_NAME="bedrock-${BRANCH_AND_COMMIT}"

rm -rf static
# have to rerun staticfiles without symlinks or we just copy broken symlinks
docker-compose run --name "$CONTAINER_NAME" release docker/bin/build_staticfiles.sh --nolink
docker cp "${CONTAINER_NAME}:/app/static" ./static
docker rm -f "$CONTAINER_NAME"

cd static
for BUCKET in stage prod; do
    # hashed filenames
    aws s3 sync \
        --exclude "*" \
        --include "*.????????????.*" \
        --acl public-read \
        --cache-control "max-age=315360000, public, immutable" \
        --profile bedrock-media \
        . "s3://bedrock-${BUCKET}-media/"
    # non-hashed filenames
    # may not need to include non-hashed files
    # TODO look into this if this is slow or makes the bucket too large
    aws s3 sync \
        --exclude "*.????????????.*" \
        --acl public-read \
        --cache-control "max-age=21600, public" \
        --profile bedrock-media \
        . "s3://bedrock-${BUCKET}-media/"
done

cd ..
rm -rf static<commit_msg>Put all media in s3 in a "media" folder to match site paths (#5934)<commit_after>#!/bin/bash

set -exo pipefail

source docker/bin/set_git_env_vars.sh

if [[ "$BRANCH_NAME" != "prod" ]]; then
    # nothing to do if not prod deployment
    exit 0
fi

CONTAINER_NAME="bedrock-${BRANCH_AND_COMMIT}"

rm -rf static
# have to rerun staticfiles without symlinks or we just copy broken symlinks
docker-compose run --name "$CONTAINER_NAME" release docker/bin/build_staticfiles.sh --nolink
docker cp "${CONTAINER_NAME}:/app/static" ./static
docker rm -f "$CONTAINER_NAME"

for BUCKET in stage prod; do
    # hashed filenames
    aws s3 sync \
        --exclude "*" \
        --include "*.????????????.*" \
        --acl public-read \
        --cache-control "max-age=315360000, public, immutable" \
        --profile bedrock-media \
        ./static "s3://bedrock-${BUCKET}-media/media/"
    # non-hashed filenames
    # may not need to include non-hashed files
    # TODO look into this if this is slow or makes the bucket too large
    aws s3 sync \
        --exclude "*.????????????.*" \
        --acl public-read \
        --cache-control "max-age=21600, public" \
        --profile bedrock-media \
        ./static "s3://bedrock-${BUCKET}-media/media/"
done

rm -rf static
{'fraction_non_alphanumeric': 0.14603559870550162, 'fraction_numerical': 0.017394822006472493, 'mean_word_length': 2.512784090909091, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5686555', 'n_tokens_mistral': 855, 'n_tokens_neox': 810, 'n_words': 241}