Make Slash Webtasks run code directly off GitHub. This is done by making the webtask load the code from GitHub and evaluate it in webtask’s context.
-
Allows Slash Webtasks to be version-controlled and collaboratively edited.
-
Uses the GitHub Apps API, so it does not require a personal access token.
-
Create a GitHub app.
-
For organizations: Go to your organization settings → Developer settings → GitHub Apps → New GitHub App
For personal account: Go to user settings → Developer settings → GitHub Apps → New GitHub App
-
Set up your GitHub App permissions as follows:
- Repository contents: Read-only
-
Generate and download a Private Key.
-
Note the App ID.
-
Install the app, granting access to the repository where the webtask code is stored.
-
Note the Installation ID which is in the URL.
-
-
Create a Slash webtask.
-
In Slack, run
/wt make hello
and click the resulting edit link. -
Copy the existing code as-is, and put it in your GitHub Repository. Example: hello.js
-
Put in this code, change things as required:
module.exports = require('slash-webtask-github-sourcer')({ owner: 'taskworld', repo: 'slash-webtask-github-sourcer', appId: 12345, installationId: 1234567, path: 'hello.js', // ref: 'master', // If you want to use a specific branch })
-
Configure the webtask Secrets → Add Secret
- Secret key: GH_APP_PRIVATE_KEY_BASE64
- Secret value: (encode the Private Key using Base64 and paste it here)
-
Configure the webtask npm Modules → Add Module → Type in slash-webtask-github-sourcer.
-
-
Try it out! Run
/wt hello
in Slack.