Close

June 1, 2023

Webhooks are here: Integrate Software Heritage with Your Development Workflow!

We have exciting news to share! As part of our mission to collect, preserve and share all software source code, we have been working to make it easy for developers to regularly archive their software in Software Heritage by introducing the dedicated save code webhooks in the API.

Webhooks are a powerful tool for automation. In the realm of code hosting platforms, they are an essential bridge between events and actions. They trigger a predefined action whenever a particular event occurs in your repository – and now, Software Heritage supports them too!

Why is this exciting?

With this new feature, integrating the archival of your code into your workflow is a matter of a few clicks. You can now set up save code webhooks on your favorite code hosting platforms, such as Bitbucket, Gitea, GitHub, GitLab, GitLab instances and Sourceforge, to automatically trigger archival in Software Heritage. Typical events that can trigger this action include tag or branch creation, release creation, and so on.

This automation ensures that important versions of your code are preserved and accessible as part of the Software Heritage archive, even amidst the hustle and bustle of development. It is essentially making code preservation a part of your continuous integration/continuous deployment (CI/CD) pipeline.

How can you set it up?

Setting up the save code webhooks in your repositories is a straightforward process, it’s just a matter of copying the URL of the Software Heritage webhook API entrypoint appropriate for the code hosting platform you use: look at the documentation for the Bitbucket endpoint, Gitea endpoint, GitHub endpoint, GitLab endpoint (and all its instances), and SourceForge endpoint.

To make it even more accessible and user-friendly, we have prepared detailed step-by-step video tutorials for several of these platforms.

Setting up Webhooks on GitHub

Let’s take a look at an example of how to configure the save code webhook on GitHub. For your convenience, this is the Payload URL that you can copy/paste directly:

https://archive.softwareheritage.org/api/1/origin/save/webhook/github/

The recommended settings for GitHub are: trigger archival on branch, tag or release creation, and not on every push event.

 

Get the SWHID of a directory

Setting up Webhooks on Bitbucket

Here is an example of how to configure the save code webhook on Bitbucket.
For your convenience, this is the URL that you can copy/paste directly:

https://archive.softwareheritage.org/api/1/origin/save/webhook/bitbucket/

The recommended settings for Bitbucket are: trigger archival on repository push and update.

Get the SWHID of a directory

Setting up Webhooks on GitLab (and its instances)

Here is an example of how to configure the save code webhook on GitLab.
For your convenience, this is the URL that you can copy/paste directly:

https://archive.softwareheritage.org/api/1/origin/save/webhook/gitlab/

The recommended settings for GitLab are: trigger archival on tag push and release creation, and not on every push event.

Get the SWHID of a directory

By integrating Software Heritage save code webhooks into your development workflow, you’ll be preserving your valuable work for posterity, and contribute to making it easily referenceable with the SWHID intrinsic identifiers.

Remember, you’re not just writing code, you’re creating software heritage. Let’s work together to ensure this heritage stands the test of time!

June 1, 2023