Prefer GH actions data when constructing upstream URL.

This commit is contained in:
Alexander Artemenko 2021-02-07 02:32:16 +03:00
parent 18f481aa61
commit 6fb3662ee6

View file

@ -92,33 +92,37 @@ behaviour could be overriden by keyword argument ``:raise t``."
(defun get-origin-to-push () (defun get-origin-to-push ()
(let ((upstream (get-git-upstream))) (cond
;; If we are running inside github actions
((uiop:getenv "GITHUB_ACTIONS")
(unless (uiop:getenv "GITHUB_TOKEN")
(error 'unable-to-proceed
:message "Please, provide GITHUB_TOKEN environment variable."))
(format nil "https://~A:~A@github.com/~A"
(uiop:getenv "GITHUB_ACTOR")
(uiop:getenv "GITHUB_TOKEN")
(uiop:getenv "GITHUB_REPOSITORY")))
;; otherwise make it from travis secret token and repo slug
((uiop:getenv "TRAVIS_REPO_SLUG")
(let ((repo-slug (uiop:getenv "TRAVIS_REPO_SLUG"))
(repo-token (uiop:getenv "GH_REPO_TOKEN")))
(cond (unless (and repo-slug repo-token)
(upstream
;; If there is already some remote upstream, then use it
(run (concatenate 'string "git remote get-url " upstream)))
;; If we are running inside github actions
((uiop:getenv "GITHUB_ACTIONS")
(unless (uiop:getenv "GITHUB_TOKEN")
(error 'unable-to-proceed (error 'unable-to-proceed
:message "Please, provide GITHUB_TOKEN environment variable.")) :message "Current branch does not track any upstream and there is no TRAVIS_REPO_SLUG and GH_REPO_TOKEN env variables. Where to push gh-pages branch?"))
(format nil "https://~A:~A@github.com/~A"
(uiop:getenv "GITHUB_ACTOR")
(uiop:getenv "GITHUB_TOKEN")
(uiop:getenv "GITHUB_REPOSITORY")))
;; otherwise make it from travis secret token and repo slug
(t
(let ((repo-slug (uiop:getenv "TRAVIS_REPO_SLUG"))
(repo-token (uiop:getenv "GH_REPO_TOKEN")))
(unless (and repo-slug repo-token) (format nil "https://~A@github.com/~A"
(error 'unable-to-proceed repo-token
:message "Current branch does not track any upstream and there is no TRAVIS_REPO_SLUG and GH_REPO_TOKEN env variables. Where to push gh-pages branch?")) repo-slug)))
;; If there is already some remote upstream, then use it
(format nil "https://~A@github.com/~A" (t
repo-token (let ((upstream (get-git-upstream)))
repo-slug)))))) (cond
(upstream
(run (concatenate 'string "git remote get-url " upstream)))
(t
(log:error "Unable to guess correct upstream URL")
(values nil)))))))
(defun push-gh-pages (docs-dir) (defun push-gh-pages (docs-dir)