check_website.yml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. name: Check website
  2. on:
  3. push:
  4. branches:
  5. - master
  6. jobs:
  7. check_freshness:
  8. name: Check freshness
  9. if: github.repository == 'elves/elvish'
  10. runs-on: ubuntu-latest
  11. strategy:
  12. matrix:
  13. host: [cdg, hkg]
  14. steps:
  15. - name: Checkout code
  16. uses: actions/checkout@v2
  17. - name: Compare timestamp
  18. timeout-minutes: 30
  19. run: |
  20. ts=$(git show -s --format=%ct HEAD)
  21. wait=10
  22. while true; do
  23. website_ts=$(curl -sS https://${{ matrix.host }}.elv.sh/commit-ts.txt)
  24. if test -z "$website_ts"; then
  25. echo "website has no commit-ts.txt yet"
  26. elif test "$website_ts" -ge "$ts"; then
  27. echo "website ($website_ts) >= current ($ts)"
  28. exit 0
  29. else
  30. echo "website ($website_ts) < current ($ts)"
  31. fi
  32. sleep $wait
  33. test $wait -lt 96 && wait=`echo "$wait * 2" | bc`
  34. done
  35. build_binaries:
  36. name: Build binaries
  37. runs-on: ubuntu-latest
  38. steps:
  39. - name: Checkout code
  40. uses: actions/checkout@v2
  41. - name: Set up cache
  42. uses: actions/cache@v2
  43. with:
  44. path: |
  45. ~/go/pkg/mod
  46. ~/.cache/go-build
  47. key: buildall/${{ matrix.os }}/1.19.x/${{ hashFiles('go.sum') }}/${{ github.sha }}
  48. restore-keys: buildall/${{ matrix.os }}/1.19.x/${{ hashFiles('go.sum') }}
  49. - name: Set up Go
  50. uses: actions/setup-go@v2
  51. with:
  52. # Keep this in sync with
  53. # https://github.com/elves/up/blob/master/Dockerfile
  54. go-version: 1.19.3
  55. - name: Build binaries
  56. run: ELVISH_BUILD_VARIANT=official ./tools/buildall.sh . ~/elvish-bin HEAD
  57. - name: Upload binaries
  58. uses: actions/upload-artifact@v2
  59. with:
  60. name: bin
  61. path: ~/elvish-bin/**/*
  62. - name: Upload binary checksums
  63. uses: actions/upload-artifact@v2
  64. with:
  65. name: bin-checksums
  66. path: ~/elvish-bin/**/elvish-HEAD.sha256sum
  67. check_binary_checksums:
  68. name: Check binary checksums
  69. needs: [check_freshness, build_binaries]
  70. strategy:
  71. matrix:
  72. host: [cdg, hkg]
  73. runs-on: ubuntu-latest
  74. steps:
  75. - name: Download binary checksums
  76. uses: actions/download-artifact@v2
  77. with:
  78. name: bin-checksums
  79. path: elvish-bin
  80. - name: Check binary checksums
  81. working-directory: elvish-bin
  82. run: |
  83. ret=0
  84. for f in */elvish-HEAD.sha256sum; do
  85. website_sum=$(curl -sS https://${{ matrix.host }}.dl.elv.sh/$f | awk '{print $1}')
  86. github_sum=$(cat $f | awk '{print $1}')
  87. if test "$website_sum" = "$github_sum"; then
  88. echo "$f: website == github ($github_sum)"
  89. else
  90. echo "$f: website ($website_sum) != github ($github_sum)"
  91. ret=1
  92. fi
  93. done
  94. if test $ret != 0; then
  95. 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)
  96. if test ${{ github.sha }} != "$latest_sha"; then
  97. echo "Ignoring the mismatch since there is a newer commit now"
  98. ret=0
  99. fi
  100. fi
  101. exit $ret