-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
121 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
module Restyler.GHA | ||
( GitHubOutput (..) | ||
, envGitHubOutput | ||
, HasGitHubOutput (..) | ||
, setGitHubOutput | ||
, setGitHubOutputLn | ||
) where | ||
|
||
import Restyler.Prelude | ||
|
||
import Env qualified | ||
|
||
newtype GitHubOutput = GitHubOutput | ||
{ unwrap :: FilePath | ||
} | ||
deriving newtype (IsString) | ||
|
||
class HasGitHubOutput env where | ||
githubOutputL :: Lens' env GitHubOutput | ||
|
||
envGitHubOutput :: Env.Parser Env.Error GitHubOutput | ||
envGitHubOutput = Env.var Env.nonempty "GITHUB_OUTPUT" mempty | ||
|
||
setGitHubOutput | ||
:: (MonadIO m, MonadReader env m, HasGitHubOutput env) | ||
=> Text | ||
-> ByteString | ||
-> m () | ||
setGitHubOutput name value = do | ||
path <- view $ githubOutputL . to (.unwrap) | ||
liftIO $ do | ||
writeFileText path $ name <> "=" | ||
writeFileBS path value | ||
writeFileText path "\n" | ||
|
||
setGitHubOutputLn | ||
:: (MonadIO m, MonadReader env m, HasGitHubOutput env) | ||
=> Text | ||
-> ByteString | ||
-> m () | ||
setGitHubOutputLn name value = do | ||
path <- view $ githubOutputL . to (.unwrap) | ||
liftIO $ do | ||
writeFileText path $ name <> "<<EOM\n" | ||
writeFileBS path value | ||
writeFileText path "\nEOM\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters