You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a template for defining your own actions with found [here](https://github.com/colinwahl/hello-world-purescript-action). The template provides a starting point in order to define your own actions with these bindings!
20
+
An Action is an `action.yml` file pair with a Node script.
21
+
22
+
This library provides PureScript bindings to [Github's Actions Toolkit](https://github.com/actions/toolkit), which provides useful tools for writing Actions.
23
+
24
+
To write your own Action, create an `action.yml` file which specifies the inputs, outputs, and metadata which will be used by your Action. See [GitHub's docs](https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions) on the syntax of this file. Then you can use this library to write a Node script which will execute the Action based on the `action.yml` file.
25
+
26
+
You can use the [Hello World PureScript Action template](https://github.com/colinwahl/hello-world-purescript-action) to get started defining your own Action. The template provides a starting point in order to define your own actions with these bindings!
27
+
28
+
Here are some common functions which are used when defining Actions:
29
+
30
+
Get an input with key `username` specified by the `action.yml` file for use in the script, then log it:
Use `which` to check that a tool is installed, and set the job to failed if it isn't.
40
+
41
+
```purescript
42
+
main :: Effect Unit
43
+
main = do
44
+
result <- runExcaptT (IO.which { tool: "spago", check: true })
45
+
case result of
46
+
Left err ->
47
+
Core.error "spago not found"
48
+
Core.setFailed "Required tool spago is not available for this job."
49
+
Right spagoPath ->
50
+
Core.info $ "spago found at path " <> spagoPath
51
+
pure unit -- If your job ends without failing, then it succeeded.
52
+
```
53
+
54
+
Run an arbitrary command with `exec`.
55
+
56
+
```purescript
57
+
main :: Effect Unit
58
+
main = do
59
+
result <- runExceptT (Exec.exec' "spago build")
60
+
case result of
61
+
Left err ->
62
+
-- Something bad happened, log error and set failed
63
+
Core.error $ message err
64
+
Core.setFailed "Exception was thrown during spago build"
65
+
Right returnCode | returnCode == 0.0 ->
66
+
Core.info "spago build succeeded"
67
+
Right returnCode ->
68
+
Core.warning $ "spago build failed with ruturn code" <> returnCode
69
+
Core.setFailed "spago exited with nonzero return code"
70
+
```
71
+
72
+
You can find documentation for all of the functions in this library in [the docs directory](./docs).
21
73
22
74
## Documentation
23
75
24
76
GitHub Actions Toolkit documentation is stored in a few places:
25
77
26
78
1. Module documentation is [published on Pursuit](https://pursuit.purescript.org/packages/purescript-github-actions-toolkit).
27
79
2. Written documentation and [the changelog](./docs/CHANGELOG.md) are kept in [the docs directory](./docs).
28
-
3. Usage examples can be found in [the test suite](./test).
80
+
81
+
For a usage example, see the [Hello World PureScript Action template](https://github.com/colinwahl/hello-world-purescript-action). For a real-world action that uses these bindings, see [Setup PureScript](https://github.com/purescript-contrib/setup-purescript).
29
82
30
83
If you get stuck, there are several ways to get help:
A [GitHub Action](https://github.com/features/actions) is a script which allows you to automate your GitHub workflows.
4
+
5
+
Specifically, an Action is an `action.yml` file paired with a Node script (found in `dist/index.js`). The `action.yml` file defines the inputs, outputs, and other metadata used by the Action, which the user can control in their own project. GitHub will execute your Node script with the parameters from the `action.yml` file after various events such as pushing to a branch or creating a pull request. Once you publish a GitHub Action, it can be used in other repositories to automate their workflows.
6
+
7
+
### What is GitHub's Actions Toolkit?
8
+
9
+
[GitHub's Actions Toolkit](https://github.com/actions/toolkit) is a set of Node modules which provide useful tools for creating Actions. For example:
10
+
11
+
`GitHub.Actions.Core` provides bindings to the [core](https://github.com/actions/toolkit/tree/main/packages/core) package, which allows you to
0 commit comments