|
| 1 | +#!/bin/bash |
| 2 | +set -e |
| 3 | +set +x |
| 4 | + |
| 5 | +if [[ $(uname) != "Linux" ]]; then |
| 6 | + echo "ERROR: this script is designed to be run on Linux. Can't run on $(uname)" |
| 7 | + exit 1 |
| 8 | +fi |
| 9 | + |
| 10 | +CURRENT_HOST_OS="$(bash -c 'source /etc/os-release && echo $NAME')" |
| 11 | +CURRENT_HOST_OS_VERSION="$(bash -c 'source /etc/os-release && echo $VERSION_ID')" |
| 12 | + |
| 13 | +if [[ "$CURRENT_HOST_OS" != "Ubuntu" || "$CURRENT_HOST_OS_VERSION" != "20.04" ]]; then |
| 14 | + echo "ERROR: this script is designed to be run on Ubuntu 20.04. Can't run on $CURRENT_HOST_OS $CURRENT_HOST_OS_VERSION" |
| 15 | + exit 1 |
| 16 | +fi |
| 17 | + |
| 18 | +if [[ ($1 == '--help') || ($1 == '-h') ]]; then |
| 19 | + echo "usage: $(basename $0)" |
| 20 | + echo |
| 21 | + echo "Pull from upstream & run checkout_build_archive_upload.sh" |
| 22 | + echo "in a safe way so that multiple instances of the script cannot be run" |
| 23 | + echo |
| 24 | + echo "This script is designed to be run as a cronjob" |
| 25 | + exit 0 |
| 26 | +fi |
| 27 | + |
| 28 | +if [[ (-z $AZ_ACCOUNT_KEY) || (-z $AZ_ACCOUNT_NAME) ]]; then |
| 29 | + echo "ERROR: Either \$AZ_ACCOUNT_KEY or \$AZ_ACCOUNT_NAME environment variable is missing." |
| 30 | + echo " 'Azure Account Name' and 'Azure Account Key' secrets that are required" |
| 31 | + echo " to upload builds ot Azure CDN." |
| 32 | + exit 1 |
| 33 | +fi |
| 34 | + |
| 35 | +if ! command -v az >/dev/null; then |
| 36 | + echo "ERROR: az is not found in PATH" |
| 37 | + exit 1 |
| 38 | +fi |
| 39 | + |
| 40 | +# Setup a LOCKDIR so that we don't run the same script multiple times. |
| 41 | +LOCKDIR="/tmp/$(basename $0).lock" |
| 42 | +if [[ -d ${LOCKDIR} ]]; then |
| 43 | + echo "Already running (lockdir $LOCKDIR exists. Remove it manually if running)" |
| 44 | + exit 0 |
| 45 | +fi |
| 46 | + |
| 47 | +mkdir -p $LOCKDIR |
| 48 | +# make sure the lockfile is removed when we exit and then claim it |
| 49 | +trap "rm -rf ${LOCKDIR}; cd $(pwd -P); exit" INT TERM EXIT |
| 50 | +cd "$(dirname "$0")" |
| 51 | + |
| 52 | +IS_FIRST_RUN_FILE="/tmp/pw-buildbot-first-run.txt"; |
| 53 | +if ! [[ -f $IS_FIRST_RUN_FILE ]]; then |
| 54 | + source ./send_telegram_message.sh |
| 55 | + send_telegram_message '**Linux Buildbot Is Active**' |
| 56 | +fi |
| 57 | +touch "$IS_FIRST_RUN_FILE" |
| 58 | + |
| 59 | +# Check if git repo is dirty. |
| 60 | +if [[ -n $(git status -s) ]]; then |
| 61 | + echo "ERROR: dirty GIT state - commit everything and re-run the script." |
| 62 | + exit 1 |
| 63 | +fi |
| 64 | + |
| 65 | +git pull origin master |
| 66 | +../checkout_build_archive_upload.sh webkit-gtk-ubuntu-20.04 >/tmp/$(basename $0)--webkit-gtk.log || true |
| 67 | +../checkout_build_archive_upload.sh webkit-wpe-ubuntu-20.04 >/tmp/$(basename $0)--webkit-wpe.log || true |
| 68 | +../checkout_build_archive_upload.sh webkit-gtk-wpe-ubuntu-20.04 >/tmp/$(basename $0)--webkit-gtk-wpe.log || true |
0 commit comments