Start Ngrok only when there is a token.

This commit is contained in:
Alexander Artemenko 2021-02-07 15:02:42 +03:00
parent 6e25fdff44
commit 3f88c8ad46

View file

@ -29,10 +29,11 @@ exec ros -Q -- $0 "$@"
((stdout :initarg :stdout :reader subprocess-error-stdout) ((stdout :initarg :stdout :reader subprocess-error-stdout)
(stderr :initarg :stderr :reader subprocess-error-stderr)) (stderr :initarg :stderr :reader subprocess-error-stderr))
(:report (lambda (condition stream) (:report (lambda (condition stream)
(format stream "Subprocess ~@[~S~% ~]~@[with command ~S~% ~]exited with error~@[ code ~D ~]~@[ and this text at stderr:~% ~S~]" (format stream "Subprocess ~@[~S~% ~]~@[with command ~S~% ~]exited with error~@[ code ~D ~]~@[~%STDOUT:~% ~S~]~@[~%STDERR:~% ~S~]"
(uiop:subprocess-error-process condition) (uiop:subprocess-error-process condition)
(uiop:subprocess-error-command condition) (uiop:subprocess-error-command condition)
(uiop:subprocess-error-code condition) (uiop:subprocess-error-code condition)
(subprocess-error-stdout condition)
(subprocess-error-stderr condition))))) (subprocess-error-stderr condition)))))
@ -77,8 +78,11 @@ behaviour could be overriden by keyword argument ``:raise t``."
(defun git-repository-was-changed-p () (defun git-repository-was-changed-p ()
;; if git status returns something, then repository have uncommitted changes ;; Here we only interested in entries which are starting from 1 (changed in porcelain v2 format).
(> (length (git "status --porcelain | grep -v qlfile")) ;; And not in qlfile and qlfile.lock.
;; The "cat" at the end is to make 0 status code if there is no changed files.
;; Because we only want an output from grep.
(> (length (git "status --porcelain=v2 | grep '^1' | grep -v -e qlfile | cat"))
0)) 0))
@ -148,7 +152,8 @@ behaviour could be overriden by keyword argument ``:raise t``."
(git "push --force origin master:gh-pages")) (git "push --force origin master:gh-pages"))
;; or ;; or
(t (log:info "Everything is up to date."))))) (t (log:info "Everything is up to date."))))
(values))
(defun push-local-changes () (defun push-local-changes ()
@ -197,7 +202,8 @@ behaviour could be overriden by keyword argument ``:raise t``."
(t (t
(if-there-are-changes (if-there-are-changes
(make-commit) (make-commit)
(git "push")))))))) (git "push")))))))
(values))
(defun main (&rest argv) (defun main (&rest argv)
@ -223,13 +229,14 @@ behaviour could be overriden by keyword argument ``:raise t``."
:if-exists :overwrite) :if-exists :overwrite)
(declare (ignorable s))) (declare (ignorable s)))
(when (uiop:getenv "NGROK_AUTH_TOKEN")
(let ((url (ngrok/slynk:start 4005))) (let ((url (ngrok/slynk:start 4005)))
(when url (when url
(log:info "Waiting for connection to ~A" url) (log:info "Waiting for connection to ~A" url)
(log:info "do touch ~~/continue to let process continue" ) (log:info "do touch ~~/continue to let process continue" )
(loop (loop
until (probe-file "~/continue") until (probe-file "~/continue")
do (sleep 5)))) do (sleep 5)))))
(push-gh-pages docs-dir) (push-gh-pages docs-dir)
(push-local-changes)))) (push-local-changes))))