GitHub v3 REST API

Get a repository secret

Gets a single repository secret without revealing its encrypted value. You must authenticate using an access token with the repo scope to use this endpoint. GitHub Apps must have the secrets repository permission to use this endpoint.

get
{protocol}://{hostname}/api/v3/repos/{owner}/{repo}/actions/secrets/{secret_name}

Path Parameters

ownerstringrequired
repostringrequired
secret_namestringrequired

secret_name parameter

Response

200 application/json

Response

Actions Secret

Set secrets for GitHub Actions.

namestringrequired

The name of the secret.

Example:SECRET_TOKEN

created_atstring(date-time)required
updated_atstring(date-time)required
get/repos/{owner}/{repo}/actions/secrets/{secret_name}
 
200 application/json

Create or update a repository secret

Creates or updates a repository secret with an encrypted value. Encrypt your secret using
LibSodium. You must authenticate using an access
token with the repo scope to use this endpoint. GitHub Apps must have the secrets repository permission to use
this endpoint.

Example encrypting a secret using Node.js

Encrypt your secret using the tweetsodium library.

const sodium = require('tweetsodium');

const key = "base64-encoded-public-key";
const value = "plain-text-secret";

// Convert the message and key to Uint8Array's (Buffer implements that interface)
const messageBytes = Buffer.from(value);
const keyBytes = Buffer.from(key, 'base64');

// Encrypt using LibSodium.
const encryptedBytes = sodium.seal(messageBytes, keyBytes);

// Base64 the encrypted secret
const encrypted = Buffer.from(encryptedBytes).toString('base64');

console.log(encrypted);

Example encrypting a secret using Python

Encrypt your secret using pynacl with Python 3.

from base64 import b64encode
from nacl import encoding, public

def encrypt(public_key: str, secret_value: str) -> str:
  """Encrypt a Unicode string using the public key."""
  public_key = public.PublicKey(public_key.encode("utf-8"), encoding.Base64Encoder())
  sealed_box = public.SealedBox(public_key)
  encrypted = sealed_box.encrypt(secret_value.encode("utf-8"))
  return b64encode(encrypted).decode("utf-8")

Example encrypting a secret using C#

Encrypt your secret using the Sodium.Core package.

var secretValue = System.Text.Encoding.UTF8.GetBytes("mySecret");
var publicKey = Convert.FromBase64String("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvvcCU=");

var sealedPublicKeyBox = Sodium.SealedPublicKeyBox.Create(secretValue, publicKey);

Console.WriteLine(Convert.ToBase64String(sealedPublicKeyBox));

Example encrypting a secret using Ruby

Encrypt your secret using the rbnacl gem.

require "rbnacl"
require "base64"

key = Base64.decode64("+ZYvJDZMHUfBkJdyq5Zm9SKqeuBQ4sj+6sfjlH4CgG0=")
public_key = RbNaCl::PublicKey.new(key)

box = RbNaCl::Boxes::Sealed.from_public_key(public_key)
encrypted_secret = box.encrypt("my_secret")

# Print the base64 encoded secret
puts Base64.strict_encode64(encrypted_secret)
put
{protocol}://{hostname}/api/v3/repos/{owner}/{repo}/actions/secrets/{secret_name}

Path Parameters

ownerstringrequired
repostringrequired
secret_namestringrequired

secret_name parameter

Body

application/json
encrypted_valuestring

Value for your secret, encrypted with LibSodium using the public key retrieved from the Get a repository public key endpoint.

Match pattern:^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})$

key_idstring

ID of the key you used to encrypt the secret.

Response

application/json

Response when creating a secret

object
* Additional properties are NOT allowed.
put/repos/{owner}/{repo}/actions/secrets/{secret_name}

Body

{ "encrypted_value": "c2VjcmV0", "key_id": "012345678912345678" }
 
application/json

Delete a repository secret

Deletes a secret in a repository using the secret name. You must authenticate using an access token with the repo scope to use this endpoint. GitHub Apps must have the secrets repository permission to use this endpoint.

delete
{protocol}://{hostname}/api/v3/repos/{owner}/{repo}/actions/secrets/{secret_name}

Path Parameters

ownerstringrequired
repostringrequired
secret_namestringrequired

secret_name parameter

Response

204

Response

delete/repos/{owner}/{repo}/actions/secrets/{secret_name}
 
204

List repository workflows

Lists the workflows in a repository. Anyone with read access to the repository can use this endpoint. If the repository is private you must use an access token with the repo scope. GitHub Apps must have the actions:read permission to use this endpoint.

get
{protocol}://{hostname}/api/v3/repos/{owner}/{repo}/actions/workflows

Query Parameters

per_pageinteger

Results per page (max 100)

Default:30

pageinteger

Page number of the results to fetch.

Default:1

Path Parameters

ownerstringrequired
repostringrequired

Response

200 application/json

Response

total_countintegerrequired
workflowsarray[object]required

A GitHub Actions workflow

Show Child Parameters
get/repos/{owner}/{repo}/actions/workflows
 
200 application/json

Get a workflow

Gets a specific workflow. You can replace workflow_id with the workflow file name. For example, you could use main.yaml. Anyone with read access to the repository can use this endpoint. If the repository is private you must use an access token with the repo scope. GitHub Apps must have the actions:read permission to use this endpoint.

get
{protocol}://{hostname}/api/v3/repos/{owner}/{repo}/actions/workflows/{workflow_id}

Path Parameters

ownerstringrequired
repostringrequired
workflow_idOne Of
required

The ID of the workflow. You can also pass the workflow file name as a string.

Variant 1integer

Response

200 application/json

Response

Workflow

A GitHub Actions workflow

idintegerrequired

Example:5

node_idstringrequired

Example:MDg6V29ya2Zsb3cxMg==

namestringrequired

Example:CI

pathstringrequired

Example:ruby.yaml

statestringrequired

Allowed values:activedeleteddisabled_forkdisabled_inactivitydisabled_manually

Example:active

created_atstring(date-time)required

Example:2019-12-06T14:20:20.000Z

updated_atstring(date-time)required

Example:2019-12-06T14:20:20.000Z

urlstringrequired

Example:https://api.github.com/repos/actions/setup-ruby/workflows/5

html_urlstringrequired

Example:https://github.com/actions/setup-ruby/blob/master/.github/workflows/ruby.yaml

badge_urlstringrequired

Example:https://github.com/actions/setup-ruby/workflows/CI/badge.svg

deleted_atstring(date-time)

Example:2019-12-06T14:20:20.000Z

get/repos/{owner}/{repo}/actions/workflows/{workflow_id}
 
200 application/json