forked from foundriesio/fioctl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrefresh-metadata.sh
executable file
·34 lines (30 loc) · 1.02 KB
/
refresh-metadata.sh
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
#!/bin/sh -e
tuf_bin=/tmp/tuf
curl -L https://github.com/theupdateframework/go-tuf/releases/download/v0.6.0/tuf_0.6.0_linux_amd64.tar.gz | tar -C /tmp -xz tuf > ${tuf_bin}
if [ "$(md5sum ${tuf_bin})" != "27fed62ea9c176b7866828be3e0fd42b ${tuf_bin}" ] ; then
echo "Invalid tuf binary"
exit 1
fi
chmod +x ${tuf_bin}
git config user.name github-actions
git config user.email [email protected]
if ! ${tuf_bin} status --valid-at "`date --rfc-3339=seconds -d '+8 hour' | sed 's/ /T/'`" snapshot ; then
echo "refreshing snapshot and timestamp metadata"
${tuf_bin} snapshot --expires=7
${tuf_bin} timestamp
${tuf_bin} commit
else
if ! ${tuf_bin} status --valid-at "`date --rfc-3339=seconds -d '+8 hour' | sed 's/ /T/'`" timestamp ; then
echo "refreshing timestamp metadata"
${tuf_bin} timestamp
${tuf_bin} commit
fi
fi
git add repository/*
if [ -z "$(git status --porcelain)" ] ; then
echo "metadata does not need refreshing"
else
echo "committing changes to metadata"
git commit -m "updated by github action"
git push
fi