This application is a Github webhook listener that listens for JIRA tickets to be moved to a specific status, and then automatically approves and merges the corresponding pull request in GitHub.
- A GitHub account and access to a repository
- A JIRA account and access to a project
- A DigitalOcean account (or other serverless functions hoster)
- doctl (DigitalOcean command line tool) installed and configured on your local machine (if using DO - otherwise make sure to take a look at the build.sh script and adjust the commands accordingly)
- Node.js and npm (Node Package Manager) installed on your local machine
This setup is was made specifically for Digitalocean so if you want to use another serverless functions hoster you will need to adjust the build.sh script accordingly and may do some changes to the code.
- Clone the repository to your local machine.
- In the project root directory, run
npm install
to install the dependencies. - Create a new function in DigitalOcean using the doctl command line tool by running doctl compute function create <FUNCTION_NAME>.
- Build the project and deploy to DigitalOcean by running the do-init.sh script in the project root directory.
- Go to JIRA Actions and create an action that triggers a webhook POST. In the webhook settings, set the payload URL to the URL of your DigitalOcean function, and choose any trigger.
- In the root directory of the project, create a new file called .env and add the following environment variables: GITHUB_CLASSIC_TOKEN. This token is used for authenticating with the GitHub API. You can create a new token by going to your GitHub settings and selecting "Personal access tokens".
# run watcher simply run
npm run watch
This will watch for changes in the project, copy them to the build folder and deploy the function to DigitalOcean.
--
# run tests
npm run lint
The function can be deployed to DigitalOcean using the doctl command line tool. To deploy the function and start watching for changes, run the following command in the project root directory:
doctl compute function deploy <FUNCTION_NAME> --watch
You can also use the command doctl compute function create <FUNCTION_NAME>
to create a new function in DigitalOcean.
Alternatively you want to use packages.scripts in package.json - like npm run watch - which will also deploy the function to DigitalOcean and watch or use do-init.sh to deploy the function once. This script can be executed multiple times to update the function.
You will need to create a new webhook in the JIRA automation settings. The webhook should send a payload to the URL of your DigitalOcean function.
{
"project": "{{project.name}}",
"key": "{{issue.key}}",
"status": "{{issue.status.name}}",
"github_repo_name": "my-repo",
"github_repo_owner": "my-username[OR]organization-name",
}
Make sure to keep your tokens and credentials safe and do not share them with anyone.
The Unlicense (Public Domain) - see the LICENSE file for details