Trigger GitHub Actions Workflow from ReARM
N.B. This functinality is not part of ReARM Community Edition and is only available on Enterprise Edition.
GitHub Part
- You need to register a GitHub application that would trigger events in your repositories. To do so, refer to instructions here.
Leave most values at their defaults, uncheck Active
on Webhook, and set the following permissions: Repository Permissions -> Contents -> Access: Read and write.
Select to install for only this account or other accounts as well based on your organization needs. Note, that currently ReARM allows integration with only one GitHub App per ReARM organization.
Once the GitHub App is created, note its App ID.
Generate App Private Key as suggested by GitHub (on the home page of your app scroll down to the
Private keys
section and click onGenerate a private key
). A .pem file would be downloaded onto your machine.From your bash terminal, perform the following commands on this .pem file (I would assume the file to be named
key.pem
for the commands below):
openssl pkcs8 -topk8 -inform PEM -outform DER -in key.pem -out key.der -nocrypt
base64 -w 0 key.der
Note the output, you would need it to paste into ReARM integration form.
- In your browser, from the home page of your GitHub App, click on the
Install App
and install it for desired Account(s) and repository or repositories.
Once installed, the App would display installation ID in the browser address bar as shown on the image below.
Note this installation ID for adding into ReARM integration form later.
- Create a desired GitHub Actions script in your repository which would fire on repository dispatch event, i.e.
on:
repository_dispatch:
types: [reliza-build-event]
See sample script here.
This script must be present on the main branch of your repository as GitHub Actions does not support branch selection for triggers.
Note that the event type is optional, and you can choose any event and configure it on ReARM.
In your script, you may also make use of client payload as described in the GitHub Documentation here.
ReARM Part
Note that for integration triggers firing on approval policy events, you would need an Approval Policy configured; for firing on vulnerabilities or policy violations, you would need Dependency Track integration configured.
Organization-Wide CI Integration Part (requires Organization Admin permissions)
In ReARM, open Organization Settings menu. Under Integrations tab, in the
CI Integrations
sub-section, click onAdd CI Integration
.Enter description (try to make this descriptive as this will be used to identify integration).
Choose
GitHub
as CI Type.Paste your Base64-encoded key noted above in the
GitHub Private Key DER Base64
field.Enter your GitHub App noted above in the
GitHub Application ID
field.Click
Save
. Your CI Integration is now created.
Component Part (requires User with Write permissions)
In ReARM, make sure you register your VCS repository that contains desired GitHub Actions script either via Component creation or via VCS menu item and the plus-circle icon.
You need to set up a ReARM component that will have corresponding triggers configured. Once your component is created, open it and click on the tool icon to toggle component settings:
If you are setting triggers based on approvals, make sure you have Approval Policy selected under Core Settings tab.
Open Output Triggers tab and click on the
plus-circle icon
in the bottom left (Add Output Trigger).Enter name for your trigger, i.e.
Trigger GitHub Actions Approval Workflow
.Select
External Integration
as Type.Choose your previously created GitHub Integration in the
Choose CI Integration
fieldEnter your GitHub App's Installation ID as noted above.
Enter name of your GitHub Actions event as referenced in your GitHub Actions script (the event name used in these instructions was
reliza-build-event
).If you require any additional client payload, enter it in the JSON format in the Optional Client Payload JSON field.
Under CI Repository click on the Edit icon and select your GitHub repository containing desired GitHub Actions workflow set up above.
Click on 'Save', your trigger is now created.
Now create a Trigger Event linked to this trigger to make it fire on desired events (TODO - to be documented soon).