Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding ability to handle webhooks from Github #2

Merged
merged 2 commits into from
Feb 29, 2024
Merged

Conversation

randalldfloyd
Copy link
Contributor

@randalldfloyd randalldfloyd commented Feb 29, 2024

Overview

We would like to use forklift for automating deployments of things that are not running in containers. Since a webhook would never be called from DockerHub in those cases, we could call from Github webhooks instead.

This adds an additional endpoint that can parse the format of a GH event payload. It currently only handles the push event, but the event type is being detected so it could be expanded on to handle the many various events GH can send.

Any repo that wants to send an event payload back to forklift from GH would have to use the new endpoint like:

https://location_of_forklift.domain.com/gh_webhook?apikey=xxxxxxxxxxxxx

Configuration

The configuration of the valid_containers section requires knowing how to map the data in the GH event payload to the name and tag values. For the following payload:

{
  "ref": "refs/heads/main",
...
  "repository": {
    "id": 176407102,
...
    "name": "some_repo",
    "full_name": "IUBLibTech/some_repo"
  }  
}

The values in the forklift configuration would be:

valid_containers = {'IUBLibTech/some_repo':
                     [{'tag': 'refs/heads/main', 
                       'target': 'some_deployment_location/bin/update'}]
                   }

Copy link
Member

@dlpierce dlpierce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay, GH webhooks!

@dlpierce dlpierce merged commit 2412fc6 into main Feb 29, 2024
1 check passed
@dlpierce dlpierce deleted the github_webhook branch February 29, 2024 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants