GitHub Action
Notion github catalog
This action will scan all of the Github repositories available to the provided token and update their information in the specified Notion database.
First, you need to have an integration access token - which you can get from https://www.notion.so/my-integrations after creating an integration. Give the integration a friendly name like 'Github Actions'.
By default integrations cant access any content so you you must share your database (or the parent page / tree it is contained within) with the integration you created earlier to be able to access it.
This action expects a Notion database with the following properties:
- Name: text
- Description: text
- Kind: select
- URL: url
- Segment: select
- Team: select
- Tags: multi_select
- Visibility: select
- Language: select
- Status: select
- Updated: date
The following notion page and database is connected to the tests by default, and can be used as a template: https://infinitaslearning.notion.site/Notion-Github-Catalogue-ac2395eda37144e698e6b8faef1003c7
It looks like this after it has run:
This action expects each of your repositories to have a descriptor file format in the root of the repo in the form of a Backstage catalog-info
file. This is because we are testing this approach against using Backstage directly, and wanted to leverage a format that perhaps has a chance of becoming a defacto standard. It does not currently map all fields from Backstage, but if you look at the code you can see what it does map. I may add a config option to allow mapping to be more dynamic in future (a good PR!).
Information on the format: https://backstage.io/docs/features/software-catalog/descriptor-format
This is typically deployed as a scheduled action:
name: Catalog
on:
schedule:
- cron: '30 5 * * *'
workflow_dispatch:
jobs:
catalog:
runs-on: ubuntu-latest
steps:
- name: Notion github catalog
uses: infinitaslearning/notion-github-catalog@main
with:
github_owner: infinitaslearning
github_token: ${{ secrets.PAT_GITHUB_TOKEN }}
notion_token: ${{ secrets.NOTION_TOKEN }}
database: 2b26b4290cc84d95ad3e93c3255277a1
repository_type: all
catalog_file: catalog-info.yaml
To get the database ID, simply browse to it, click on the '...' in Notion, and get a 'Copy link'. The GUID at the end of the URL (but before the ?v=
) is the id, this works on both embedded and full page databases.
Assumes you have @vercel/ncc
installed globally.
After changes ensure you npm run build
, commit and then submit a PR.
For the tests to run you need to have the environment variables set for GITHUB_TOKEN, NOTION_TOKEN and NOTION_DATABASE.