🛠 A toolkit for building GitHub Actions in Node.js
This release includes two TypeScript changes - in an abundance of caution I've marked it as a new major version, but there aren't any changes other than the two PRs below. Have fun!
There are a couple of major improvements that are unfortunately breaking changes:
tools.context.issue
returns a different objectThanks to @mheap, tools.context.issue
now returns { owner, repo, issue_number }
instead of { owner, repo, number }
. This is due to a change in the Octokit SDK. To have parity with pull requests, there is now also tools.context.pullRequest
, which returns { owner, repo, pull_number }
.
See #118 for more information!
Toolkit#getFile
is now Toolkit#readFile
The getFile
method has been renamed to readFile
, and the behavior has changed. It now uses fs.promises.readFile
under the hood, so it returns a promise:
const tools = new Toolkit({ ... })
const contents = await tools.readFile('README.md')
See #121 for more information!
tools.store
has been removedThis feature was added before the Actions runtime had a way to share data between actions. That now exists in the platform, as "outputs"! See #125 for the removal of Store
, and #120 for it's "replacement", tools.outputs
(thanks to @abouroubi ✨):
tools.outputs.example = 'foo'
Toolkit#runInWorkspace
is now Toolkit#exec
This method was useful, but @actions/exec
is built more with the Actions runner in mind. So, now Toolkit#exec
calls @actions/exec
! This will be more stable for the finicky, ephemeral environments of Actions.
See #123 for more information!
This release only upgrades the bundled version of @octokit/rest
tov17
. See #109 for more details, but the breaking changes are best found in the @octokit/rest
release!
This release brings a lot of new features that are available in the Actions runtime, mostly by wrapping actions/toolkit.
tools.inputs
is a Proxy instance that lets you access the inputs of your action:uses: JasonEtco/example-action@master
with:
foo: bar
You can access those using tools.inputs
:
console.log(tools.inputs.foo) // -> 'bar'
Toolkit.run
will now call core.setFailed
upon failure, which sets an annotation to expose the error message more clearly in the GitHub Actions UI.Toolkit#config
has been removed. You should probably use tools.inputs
instead!tools.arguments
has been removed. You should probably use tools.inputs
instead!This release includes some package updates, improvements to the published library (thanks @kevinpollet!) and an addition of action.yml
to the generated template. This is to support GitHub Actions v2 🎉 2️⃣
This release is focused on improved TypeScript definitions and documentation upgrades! Now, types for modules that actions-toolkit directly exposes are included, so writing Actions in TypeScript should be a breeze 🌬
This release introduces breaking changes to tools.context.repo
and tools.context.issue
. Those are now properties instead of methods - here's the difference:
-tools.context.repo({
- foo: true
-})
+{
+ ...tools.context.repo
+ foo: true
+}
Usage is the same as always, but using the object spread operator instead of passing an object to a method:
tools.github.issues.create({
...tools.context.repo,
title: 'New issue'
})
This should help make those getters more clear and easier to use. As always, feel free to open an issue if you have feedback on this change!
context.issue
and context.repo
objects (#61) @jclem