Create a Github issue
Overviewโ
This guide will demonstrate how to implement a self-service action that creates GitHub issues directly from Port using synced webhooks.
This functionality streamlines project management by enabling users to create issues without leaving Port.
Prerequisitesโ
- Complete the onboarding process.
- Access to your GitHub organization with permissions to manage issues.
- Optional - Install Port's GitHub integration.
Set up data modelโ
If you haven't installed the GitHub integration, you will need to manually create a blueprint for GitHub repository.
We highly recommend that you install the GitHub integration to have such resources automatically set up for you.
Create the repository blueprint
- 
Go to your Builder page. 
- 
Click on + Blueprint.
- 
Click on the {...}button in the top right corner, and chooseEdit JSON.
- 
Add this JSON schema: GitHub Repository Blueprint (Click to expand){
 "identifier": "githubRepository",
 "title": "Repository",
 "icon": "Microservice",
 "schema": {
 "properties": {
 "readme": {
 "title": "README",
 "type": "string",
 "format": "markdown"
 },
 "url": {
 "title": "Repository URL",
 "type": "string",
 "format": "url"
 },
 "defaultBranch": {
 "title": "Default branch",
 "type": "string"
 }
 },
 "required": []
 },
 "mirrorProperties": {},
 "calculationProperties": {},
 "relations": {}
 }
- 
Click Saveto create the blueprint.
Implementationโ
You can create GitHub issues by leveraging Port's synced webhooks and secrets to directly interact with GitHub's REST API.
Add Port secretsโ
To add these secrets to your portal:
- 
Click on the ...button in the top right corner of your Port application.
- 
Click on Credentials. 
- 
Click on the Secretstab.
- 
Click on + Secretand add the following secrets:- GITHUB_TOKEN: Your GitHub Personal Access Token with the permission to create issue.
- GITHUB_ORG: Your GitHub organization or username
 
Set up self-service actionโ
Follow these steps to create the self-service action:
- 
Head to the self-service page. 
- 
Click on the + New Actionbutton.
- 
Click on the {...} Edit JSONbutton.
- 
Copy and paste this JSON configuration into the editor. Create GitHub Issue (Click to expand){
 "identifier": "create_github_issue",
 "title": "Create GitHub Issue",
 "icon": "Github",
 "description": "A self service action to open a GitHub repository issue with labels",
 "trigger": {
 "type": "self-service",
 "operation": "DAY-2",
 "userInputs": {
 "properties": {
 "title": {
 "icon": "DefaultProperty",
 "type": "string",
 "title": "Issue Title"
 },
 "labels": {
 "type": "array",
 "title": "Label",
 "description": "issue label",
 "default": [
 "bug"
 ],
 "items": {
 "enum": [
 "bug",
 "enhancement",
 "documentation",
 "dependencies",
 "question",
 "invalid",
 "duplicate"
 ],
 "enumColors": {
 "bug": "red",
 "enhancement": "turquoise",
 "documentation": "blue",
 "dependencies": "purple",
 "question": "lime",
 "invalid": "yellow",
 "duplicate": "orange"
 },
 "type": "string"
 }
 },
 "content": {
 "type": "string",
 "title": "Content",
 "format": "markdown"
 }
 },
 "required": [
 "title"
 ],
 "order": [
 "title",
 "content",
 "labels"
 ]
 },
 "blueprintIdentifier": "githubRepository"
 },
 "invocationMethod": {
 "type": "WEBHOOK",
 "url": "https://api.github.com/repos/{{ .secrets.GITHUB_ORG }}/{{ .entity.identifier }}/issues",
 "agent": false,
 "synchronized": true,
 "method": "POST",
 "headers": {
 "Content-Type": "application/json",
 "Authorization": "Bearer {{ .secrets.GITHUB_TOKEN }}",
 "Accept": "application/vnd.github+json"
 },
 "body": {
 "title": "{{ .inputs.title }}",
 "labels": "{{ .inputs.labels }}",
 "body": "{{ .inputs.content }}"
 }
 },
 "requiredApproval": false
 }
- 
Click Save.
Now you should see the Create GitHub Issue action in the self-service page. ๐
Let's test it!โ
- 
Head to the self-service page of your portal. 
- 
Choose the Create GitHub Issueaction:
- 
Enter the required information: - Issue name.
- Description of the issue.
- Label.
 
- 
Click on Execute.
- 
Done! Wait for the issue to be created in GitHub.