check_deploy.sh 918 B

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/bash
  2. set -e
  3. if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then
  4. echo "It's a PR"
  5. export SHOULD_DEPLOY="no"
  6. elif [[ "${GITHUB_EVENT_NAME}" == "push" ]]; then
  7. echo "It's a Push"
  8. export SHOULD_DEPLOY="no"
  9. else
  10. echo "It's a cron"
  11. sudo curl -sS --unix-socket /run/snapd.socket http://localhost/v2/find\?q\=codium > snap_latest.json
  12. SNAP_VERSION=$(jq -r '.result|map(select(.id == "lIZWXTqmo6LFSts5Cgk2VPlNwtysZAeH"))|last.version' snap_latest.json)
  13. echo "Snap version: ${SNAP_VERSION}"
  14. wget --quiet https://api.github.com/repos/VSCodium/vscodium/releases -O gh_latest.json
  15. GH_VERSION=$(jq -r 'sort_by(.tag_name)|last.tag_name' gh_latest.json)
  16. echo "GH version: ${GH_VERSION}"
  17. if [[ "${SNAP_VERSION}" == "${GH_VERSION}" ]]; then
  18. export SHOULD_DEPLOY="no"
  19. else
  20. export SHOULD_DEPLOY="yes"
  21. fi
  22. fi
  23. if [[ $GITHUB_ENV ]]; then
  24. echo "SHOULD_DEPLOY=$SHOULD_DEPLOY" >> $GITHUB_ENV
  25. fi