2022-07-22 00:25:18 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
set -u
|
|
|
|
set -o pipefail
|
|
|
|
|
|
|
|
if [[ "${CI:-}" != 'true' ]]
|
|
|
|
then
|
|
|
|
printf '%s\n' 'CI environment variable must be set to true'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "${CIRCLECI:-}" != 'true' ]]
|
|
|
|
then
|
|
|
|
printf '%s\n' 'CIRCLECI environment variable must be set to true'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-07-27 13:07:15 +02:00
|
|
|
if [[ "${CIRCLE_BRANCH}" != "develop" ]]
|
|
|
|
then
|
|
|
|
printf 'This is not develop branch'
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2022-07-22 00:25:18 +02:00
|
|
|
if [[ -z "${GITHUB_TOKEN:-}" ]]
|
|
|
|
then
|
|
|
|
printf '%s\n' 'GITHUB_TOKEN environment variable must be set'
|
|
|
|
exit 1
|
|
|
|
elif [[ -z "${GITHUB_TOKEN_USER:-}" ]]
|
|
|
|
then
|
|
|
|
printf '%s\n' 'GITHUB_TOKEN_USER environment variable must be set'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir temp
|
|
|
|
|
|
|
|
git config --global user.email "metamaskbot@users.noreply.github.com"
|
|
|
|
|
|
|
|
git config --global user.name "MetaMask Bot"
|
|
|
|
|
|
|
|
git clone git@github.com:MetaMask/extension_bundlesize_stats.git temp
|
|
|
|
|
2022-09-16 18:56:36 +02:00
|
|
|
{
|
|
|
|
echo " '${CIRCLE_SHA1}': ";
|
|
|
|
cat test-artifacts/chrome/mv3/bundle_size_stats.json;
|
|
|
|
echo ", ";
|
|
|
|
} >> temp/stats/bundle_size_data.temp.js
|
2022-07-22 00:25:18 +02:00
|
|
|
|
2022-09-16 18:56:36 +02:00
|
|
|
cp temp/stats/bundle_size_data.temp.js temp/stats/bundle_size_data.js
|
2022-07-22 00:25:18 +02:00
|
|
|
|
2022-09-16 18:56:36 +02:00
|
|
|
echo " }" >> temp/stats/bundle_size_data.js
|
2022-07-22 00:25:18 +02:00
|
|
|
|
|
|
|
cd temp
|
|
|
|
|
|
|
|
git add .
|
|
|
|
|
2022-09-16 18:56:36 +02:00
|
|
|
git commit --message "Adding bundle size at commit: ${CIRCLE_SHA1}"
|
2022-07-22 00:25:18 +02:00
|
|
|
|
|
|
|
repo_slug="$CIRCLE_PROJECT_USERNAME/extension_bundlesize_stats"
|
|
|
|
git push "https://$GITHUB_TOKEN_USER:$GITHUB_TOKEN@github.com/$repo_slug" main
|
|
|
|
|
|
|
|
cd ..
|
|
|
|
|
|
|
|
rm -rf temp
|