Create Git repo using Compass template and trigger GitHub Actions to run GitHub workflow

Ryunosuke Kaichi February 20, 2025

 

Due to GitHub restrictions, manual permission settings are required to run workflows in a forked repository.

When using the Compass template feature, the repository is forked, so it is not possible to automatically execute workflows prepared in the repository that is the template source.

Is there a way to automate the process from repository creation to workflow execution using Compass template feature?

1 answer

1 accepted

1 vote
Answer accepted
Enrique Serrano Valle
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 21, 2025

Hi, @Ryunosuke Kaichi !

Compass templates allow you to configure an outbound webhook that would be invoked, with the parameters defined on the template (and provided during template usage), which could then be used to execute a workflow in the repository. I understand you'd need to create such webhook handler to bridge the call from Compass to the SCM call triggering the workflow, but it sounds like this is a mechanism that you could use to solve your specific case.

You can check out this community post with an example showing how to build one of these webhooks and invoke it on template usage https://community.atlassian.com/t5/DevOps-articles/How-to-Compass-Templates/ba-p/2814556

There's also a YouTube video illustrating this full process here: https://youtu.be/79RC9nPoF_8?si=M-vZ0e-GVtx_5Na0

Ryunosuke Kaichi February 25, 2025

Hi, @Enrique Serrano Valle !

I took the community post and the youtube video as a reference, thanks!
I have an additional question.

When using a template with a webhook added, I get a 'Couldn't invoke webhook error'.
It appears that the webhook that can be added when creating a Compass template is not able to submit data with the structure we are looking for.
We believe this is why we are getting a 'Couldn't invoke webhook error'.
Specifically, we want to trigger a webhook event called repository_dispatch as shown in the image.
According to the GitHub documentation, the body parameter must have an event_type.
Below is the current structure and the structure we are looking for.
Is there any way to resolve this issue?

Current Structure:
{
"component": {
    "id": "new-component-id",
    "name": "new-component-name",
    "repository": "https://www.github.com/github-organization/new-component-name"
},
"parameters": {
    "event_type": "repository_created"
  }
}

Required Structure:
{
"event_type": "repository_created",
"component": {
    "id": "new-component-id",
    "name": "new-component-name",
    "repository": "https://www.github.com/github-organization/new-component-name"
  }
}
スクリーンショット 2025-02-25 174505.png

Enrique Serrano Valle
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 25, 2025

@Ryunosuke Kaichi I hear you; the format of the outbound webhook call that Compass makes wraps the user-input parameters under a top-level "parameters" field.

There isn't currently an in-Compass alternative to change that nesting. However, if you set up your own Webhook handler implementation (which is more or less what the example video is doing) you can remap Compass' parameters inside that handler, and then call a GitHub webhook with the structure that it would be expecting. I understand this requires you to build that intermediate handler, but it would give you full control regarding the forwarded data as well.

Like # people like this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events