git.iko.soy/typeable/compaREST
on master help sign in
Fixed an issue where running the GitHub Action on a trigger that is not a PR causes an error (#131)
commite54c58cc85f8d702871aa7692f04e3e468a14691 authoriko <ilyakooo0@gmail.com> dateThu 3 Mar 2022, 10:37 (5 years ago) parent4ac0d9c
1 file changed+13−7
github-action/Main.hs+13−7
github-action/Main.hs+13−7
@@ -9,6 +9,7 @@ import Control.Monad.Freer.GitHub
99import Control.Monad.Freer.Reader
1010import Data.OpenApi.Compare.Run
1111import Data.Text (Text)
12+import qualified Data.Text as T
1213import qualified Data.Yaml.Aeson as Yaml
1314import qualified GitHub as GH
1415import System.Environment
@@ -22,13 +23,18 @@ import Text.Pandoc.Writers
2223main :: IO ()
2324main = do
2425 cfg <- decodeEnv >>= either error pure
25− getArgs >>= \case
26− ["pre"] -> runPre cfg
27− ["run"] -> do
28− oldFile <- getEnv "OLD"
29− newFile <- getEnv "NEW"
30− runRun cfg (root cfg </> oldFile) (root cfg </> newFile)
31− _ -> error "Invalid arguments."
26+ case sha cfg of
27+ x | T.null . T.strip . GH.untagName $ x -> do
28+ putStrLn "SHA not specified. Exiting without doing anything."
29+ pure ()
30+ _ ->
31+ getArgs >>= \case
32+ ["pre"] -> runPre cfg
33+ ["run"] -> do
34+ oldFile <- getEnv "OLD"
35+ newFile <- getEnv "NEW"
36+ runRun cfg (root cfg </> oldFile) (root cfg </> newFile)
37+ _ -> error "Invalid arguments."
3238
3339runner :: Config -> Eff '[GitHub, Error GH.Error, Reader Config, IO] a -> IO a
3440runner cfg =