-
-
Notifications
You must be signed in to change notification settings - Fork 303
106 lines (102 loc) · 3.21 KB
/
check_website.yml
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
94
95
96
97
98
99
100
101
102
103
104
105
106
name: Check website
on:
push:
branches:
- master
jobs:
check_freshness:
name: Check freshness
if: github.repository == 'elves/elvish'
runs-on: ubuntu-latest
strategy:
matrix:
host: [cdg, hkg]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Compare timestamp
timeout-minutes: 30
run: |
ts=$(git show -s --format=%ct HEAD)
wait=10
while true; do
website_ts=$(curl -sS https://${{ matrix.host }}.elv.sh/commit-ts.txt)
if test -z "$website_ts"; then
echo "website has no commit-ts.txt yet"
elif test "$website_ts" -ge "$ts"; then
echo "website ($website_ts) >= current ($ts)"
exit 0
else
echo "website ($website_ts) < current ($ts)"
fi
sleep $wait
test $wait -lt 96 && wait=`echo "$wait * 2" | bc`
done
build_binaries:
name: Build binaries
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up cache
uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: buildall/${{ matrix.os }}/1.20.x/${{ hashFiles('go.sum') }}/${{ github.sha }}
restore-keys: buildall/${{ matrix.os }}/1.20.x/${{ hashFiles('go.sum') }}
- name: Set up Go
uses: actions/setup-go@v3
with:
# Keep this in sync with
# https://github.com/elves/up/blob/master/Dockerfile
go-version: 1.20.6
- name: Build binaries
run: ELVISH_BUILD_VARIANT=official ./tools/buildall.sh . ~/elvish-bin HEAD
- name: Upload binaries
uses: actions/upload-artifact@v3
with:
name: bin
path: ~/elvish-bin/**/*
retention-days: 7
- name: Upload binary checksums
uses: actions/upload-artifact@v3
with:
name: bin-checksums
path: ~/elvish-bin/**/elvish-HEAD.sha256sum
check_binary_checksums:
name: Check binary checksums
needs: [check_freshness, build_binaries]
strategy:
matrix:
host: [cdg, hkg]
runs-on: ubuntu-latest
steps:
- name: Download binary checksums
uses: actions/download-artifact@v3
with:
name: bin-checksums
path: elvish-bin
- name: Check binary checksums
working-directory: elvish-bin
run: |
ret=0
for f in */elvish-HEAD.sha256sum; do
website_sum=$(curl -sS https://${{ matrix.host }}.dl.elv.sh/$f | awk '{print $1}')
github_sum=$(cat $f | awk '{print $1}')
if test "$website_sum" = "$github_sum"; then
echo "$f: website == github ($github_sum)"
else
echo "$f: website ($website_sum) != github ($github_sum)"
ret=1
fi
done
if test $ret != 0; then
latest_sha=$(curl -sS -H 'Authorization: token ${{ secrets.GITHUB_TOKEN }}' -H 'Accept: application/vnd.github.VERSION.sha' https://api.github.com/repos/elves/elvish/commits/master)
if test ${{ github.sha }} != "$latest_sha"; then
echo "Ignoring the mismatch since there is a newer commit now"
ret=0
fi
fi
exit $ret