GitHub Actions
Overview
Prequel offers GitHub Actions to automate updates to your models and products based on .json
config files stored in your GitHub repo.
Use these to:
- Keep your model/product configs version-controlled
- Automatically sync changes to Prequel on every commit
- Define your data contract directly in code
Supported Actions
You can use the following GitHub Actions provided by Prequel:
prequel-co/apply-model-configs@v1
— upserts modelsprequel-co/apply-product-configs@v1
— upserts products
These GitHub actions utilize the Prequel API and apply config files from your repo directly into your Prequel instance.
Note that the sample is set up to update configs for your production
environment in Prequel. To set up an action that will update staging
configs, update the branches
field to point to your staging branch, and pass it your PREQUEL_STAGING_API_KEY
instead of the production one.
# This is a basic workflow to help you get started with Prequel Actions
name: Prequel Continuous Delivery
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches: [ "main" ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
sync:
name: Sync with Prequel
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Upsert Models
uses: prequel-co/apply-model-configs@v1
with:
host: https://api.prequel.co
api_key: ${{ secrets.PREQUEL_API_KEY }}
mode: export
dir: prequel/models/*.json
- name: Upsert Products
uses: prequel-co/apply-product-configs@v1
with:
host: https://api.prequel.co
api_key: ${{ secrets.PREQUEL_API_KEY }}
mode: export
dir: prequel/products/*.json
Model Config Format
Model config files live in your repo. The default locations prequel/models/*.json
and prequel/products/*.json
can be overwritten with the dir
field). Each file describes one model and is passed into the apply-model-configs
action. Data model configuration is documented in full below.
{
"model_name": "logs",
"columns": [
{
"name_in_source": "id",
"name_in_destination": "id",
"data_type": "text",
"is_primary_key": true,
"is_last_modified": false
},
{
"name_in_source": "log",
"name_in_destination": "event_log",
"description":"A descriptive text entry of the event that occured.",
"data_type": "text",
"is_primary_key": false,
"is_last_modified": false
},
{
"name_in_source": "updated_at",
"name_in_destination": "updated_at",
"data_type": "timestamp",
"is_primary_key": false,
"is_last_modified": true
}
],
"partition_by": ["date(updated_at)"],
"source_table": "source_schema.application_logs",
"source_name": "Example Production Source",
"organization_column": "organization_id"
}
Tip: Using
source_name
instead ofsource_id
provides stability across both staging and prod environments, whereassource_id
is environment-specific.
Product Config Format
Product config files live in your repo (e.g. prequel/products/*.json
) and define which models are grouped together into a "product" for sync. Each file defines one product. Product configuration is documented in more detail below.
{
"models": ["transactions"]
}
Currently, you cannot attach a model to a product from the model config itself — products must reference the model explicitly using this method.
FAQ
Can I use branch names to isolate models per environment?
Yes. A common pattern is to override model_name
based on branch name to prevent collisions. This can be done using custom scripting in your workflow or naming conventions in your files.
Where should I store these config files?
These should live in your GitHub repo (e.g., prequel/models/*.json
, prequel/products/*.json
). They are pulled by the GitHub Action and applied to Prequel automatically.
Additional resources
Updated about 13 hours ago