Home

Awesome

GitHub Actions CI demo through REST API

This is a basic demonstration of what is needed to run a GitHub Actions CI build by calling their REST API.

We are using Figmagic for this demo to demonstrate running it in CI. Even if you don't care for that specific tool, you'll get the gist of how to automate stuff in CI.

Instructions

Clone this repo and put it on GitHub.

Set secrets for the pipeline as per:

Authentication

The ideal way to authenticate is through Personal Access Tokens. Create one at the dedicated page for Personal Access Tokens.

A suitable access scope is repo.

Example call to API

Set the following headers:

Then send a payload:

POST https://api.github.com/repos/{USER_NAME}/{REPO_NAME}/actions/workflows/{WORKFLOW_FILENAME}/dispatches

{
  "ref": "main"
}

If you want to send in inputs, the format is:

{
  "ref": "main",
  "inputs": {
    "message": "No message",
    "version": "latest"
  }
}

Only inputs that the workflow expects will be allowed. If it contains anything unexpected, the call will fail.

References