2.0.0 • Published 5 years ago
probot-actions-adapter v2.0.0
:electric_plug: probot-actions-adapter
An adapter that takes a Probot app and makes it compatible with GitHub Actions
Contents
Installation
npm i -S probot-actions-adapterUsage
- Add an
action.jsto your Probot project, like the one shown below - Add an
action.ymlto your Probot project, like the one shown below - Vendor in your
node_modules, as recommended by the official Actions documentation - Optional, but recommended, update your project's README with an example workflow showing how to consume your action
Example action.js
// Require the adapter
const runProbot = require('probot-actions-adapter');
// Require your Probot app's entrypoint, usually this is just index.js
const app = require('./index');
// Adapt the Probot app for Actions
// This also acts as the main entrypoint for the Action
runProbot(app);Example action.yml
name: 'Probot app name'
description: 'Probot app description.'
runs:
using: 'node12'
main: 'action.js'See the documentation for action.yml syntax details.
Authentication
Authentication is via the GITHUB_TOKEN secret automatically provided by GitHub, which should be exposed as an environment variable, GITHUB_TOKEN. This can be achieved by including the appropriate env, jobs.<job_id>.env, or jobs.<job_id>.steps.env value in your workflow file.
Example via jobs.<job_id>.steps.env
Include the following in your workflow file, when calling your Probot action:
...
steps:
- name: My probot action
...
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
...Caveats
This adapter is designed to work well with Probot apps that are essentially stateless webhook handlers.
A few other limitations exist:
- The adapter will only work for Probot apps that receive webhook events that Actions also receives: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
- The adapter will only work for Probot apps with a permissions set that is less than, or equivalent to the permission set attached to the
GITHUB_TOKEN: https://docs.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners#token-permissions
If that's you, then great! :rocket: