summaryrefslogtreecommitdiffstats
path: root/taskcluster/docker/periodic-updates/runme.sh
blob: 368963aff679819d358940f7933f99875feba271 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash

set -xe

# Things to be set by task definition.
# --pinset --hsts --hpkp
# -b branch
# --use-mozilla-central
# -p firefox
# Artifact directory
# Artifact names.


test "${BRANCH}"
test "${PRODUCT}"

PARAMS=""

if [ -n "${USE_MOZILLA_CENTRAL}" ]
then
  PARAMS="${PARAMS} --use-mozilla-central"
fi

# TODO change these, so that they're run if the artifact location is specified?
if [ -n "${DO_HSTS}" ]
then
  PARAMS="${PARAMS} --hsts"
fi

if [ -n "${DO_HPKP}" ]
then
  PARAMS="${PARAMS} --hpkp"
fi

if [ -n "${DO_REMOTE_SETTINGS}" ]
then
  PARAMS="${PARAMS} --remote-settings"
fi

if [ -n "${DO_SUFFIX_LIST}" ]
then
  PARAMS="${PARAMS} --suffix-list"
fi

if [ -n "${DONTBUILD}" ]
then
  PARAMS="${PARAMS} -d"
fi


export ARTIFACTS_DIR="/home/worker/artifacts"
mkdir -p "$ARTIFACTS_DIR"

# duplicate the functionality of taskcluster-lib-urls, but in bash..
queue_base="$TASKCLUSTER_ROOT_URL/api/queue/v1"

# Get Arcanist API token

if [ -n "${TASK_ID}" ]
then
  curl --location --retry 10 --retry-delay 10 -o /home/worker/task.json "$queue_base/task/$TASK_ID"
  ARC_SECRET=$(jq -r '.scopes[] | select(contains ("arc-phabricator-token"))' /home/worker/task.json | awk -F: '{print $3}')
fi
if [ -n "${ARC_SECRET}" ] && getent hosts taskcluster
then
  set +x # Don't echo these
  secrets_url="${TASKCLUSTER_PROXY_URL}/api/secrets/v1/secret/${ARC_SECRET}"
  SECRET=$(curl "${secrets_url}")
  TOKEN=$(echo "${SECRET}" | jq -r '.secret.token')
elif [ -n "${ARC_TOKEN}" ] # Allow for local testing.
then
  TOKEN="${ARC_TOKEN}"
fi

if [ -n "${TOKEN}" ]
then
  cat >"${HOME}/.arcrc" <<END
{
  "hosts": {
    "https://phabricator.services.mozilla.com/api/": {
      "token": "${TOKEN}"
    }
  }
}
END
  set -x
  chmod 600 "${HOME}/.arcrc"
fi

export HGPLAIN=1

# shellcheck disable=SC2086
/home/worker/scripts/periodic_file_updates.sh -p "${PRODUCT}" -b "${BRANCH}" -a ${PARAMS}