Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: many unreleased updates to endpoint methods #607

Merged
merged 2 commits into from Jan 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
48 changes: 48 additions & 0 deletions docs/actions/addSelectedRepoToOrgVariable.md
@@ -0,0 +1,48 @@
---
name: Add selected repository to an organization variable
example: octokit.rest.actions.addSelectedRepoToOrgVariable({ org, name, repository_id })
route: PUT /orgs/{org}/actions/variables/{name}/repositories/{repository_id}
scope: actions
type: API method
---

# Add selected repository to an organization variable

Adds a repository to an organization variable that is available to selected repositories. Organization variables that are available to selected repositories have their `visibility` field set to `selected`. You must authenticate using an access token with the `admin:org` scope to use this endpoint. GitHub Apps must have the `organization_actions_variables:write` organization permission to use this endpoint.

```js
octokit.rest.actions.addSelectedRepoToOrgVariable({
org,
name,
repository_id,
});
```

## Parameters

<table>
<thead>
<tr>
<th>name</th>
<th>required</th>
<th>description</th>
</tr>
</thead>
<tbody>
<tr><td>org</td><td>yes</td><td>

The organization name. The name is not case sensitive.

</td></tr>
<tr><td>name</td><td>yes</td><td>

The name of the variable.

</td></tr>
<tr><td>repository_id</td><td>yes</td><td>

</td></tr>
</tbody>
</table>

See also: [GitHub Developer Guide documentation](https://docs.github.com/rest/actions/variables#add-selected-repository-to-an-organization-variable).
54 changes: 54 additions & 0 deletions docs/actions/addSelectedRepoToRequiredWorkflow.md
@@ -0,0 +1,54 @@
---
name: Add a repository to a required workflow
example: octokit.rest.actions.addSelectedRepoToRequiredWorkflow({ org, required_workflow_id, repository_id })
route: PUT /orgs/{org}/actions/required_workflows/{required_workflow_id}/repositories/{repository_id}
scope: actions
type: API method
---

# Add a repository to a required workflow

Adds a repository to a required workflow. To use this endpoint, the required workflow must be configured to run on selected repositories.

You must authenticate using an access token with the `admin:org` scope to use this endpoint.

For more information, see "[Required Workflows](https://docs.github.com/actions/using-workflows/required-workflows)."

```js
octokit.rest.actions.addSelectedRepoToRequiredWorkflow({
org,
required_workflow_id,
repository_id,
});
```

## Parameters

<table>
<thead>
<tr>
<th>name</th>
<th>required</th>
<th>description</th>
</tr>
</thead>
<tbody>
<tr><td>org</td><td>yes</td><td>

The organization name. The name is not case sensitive.

</td></tr>
<tr><td>required_workflow_id</td><td>yes</td><td>

The unique identifier of the required workflow.

</td></tr>
<tr><td>repository_id</td><td>yes</td><td>

The unique identifier of the repository.

</td></tr>
</tbody>
</table>

See also: [GitHub Developer Guide documentation](https://docs.github.com/rest/reference/actions#add-a-repository-to-selected-repositories-list-for-a-required-workflow).
58 changes: 58 additions & 0 deletions docs/actions/createEnvironmentVariable.md
@@ -0,0 +1,58 @@
---
name: Create an environment variable
example: octokit.rest.actions.createEnvironmentVariable({ repository_id, environment_name, name, value })
route: POST /repositories/{repository_id}/environments/{environment_name}/variables
scope: actions
type: API method
---

# Create an environment variable

Create an environment variable that you can reference in a GitHub Actions workflow.
You must authenticate using an access token with the `repo` scope to use this endpoint.
GitHub Apps must have the `environment:write` repository permission to use this endpoint.

```js
octokit.rest.actions.createEnvironmentVariable({
repository_id,
environment_name,
name,
value,
});
```

## Parameters

<table>
<thead>
<tr>
<th>name</th>
<th>required</th>
<th>description</th>
</tr>
</thead>
<tbody>
<tr><td>repository_id</td><td>yes</td><td>

The unique identifier of the repository.

</td></tr>
<tr><td>environment_name</td><td>yes</td><td>

The name of the environment.

</td></tr>
<tr><td>name</td><td>yes</td><td>

The name of the variable.

</td></tr>
<tr><td>value</td><td>yes</td><td>

The value of the variable.

</td></tr>
</tbody>
</table>

See also: [GitHub Developer Guide documentation](https://docs.github.com/rest/actions/variables#create-an-environment-variable).
28 changes: 15 additions & 13 deletions docs/actions/createOrUpdateEnvironmentSecret.md
Expand Up @@ -15,25 +15,27 @@ this endpoint.

#### Example encrypting a secret using Node.js

Encrypt your secret using the [tweetsodium](https://github.com/github/tweetsodium) library.
Encrypt your secret using the [libsodium-wrappers](https://www.npmjs.com/package/libsodium-wrappers) library.

```
const sodium = require('tweetsodium');
const sodium = require('libsodium-wrappers')
const secret = 'plain-text-secret' // replace with the secret you want to encrypt
const key = 'base64-encoded-public-key' // replace with the Base64 encoded public key

const key = "base64-encoded-public-key";
const value = "plain-text-secret";
//Check if libsodium is ready and then proceed.
sodium.ready.then(() => {
// Convert Secret & Base64 key to Uint8Array.
let binkey = sodium.from_base64(key, sodium.base64_variants.ORIGINAL)
let binsec = sodium.from_string(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 the secret using LibSodium
let encBytes = sodium.crypto_box_seal(binsec, binkey)

// Encrypt using LibSodium.
const encryptedBytes = sodium.seal(messageBytes, keyBytes);
// Convert encrypted Uint8Array to Base64
let output = sodium.to_base64(encBytes, sodium.base64_variants.ORIGINAL)

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

console.log(encrypted);
console.log(output)
});
```

#### Example encrypting a secret using Python
Expand Down
28 changes: 15 additions & 13 deletions docs/actions/createOrUpdateRepoSecret.md
Expand Up @@ -15,25 +15,27 @@ this endpoint.

#### Example encrypting a secret using Node.js

Encrypt your secret using the [tweetsodium](https://github.com/github/tweetsodium) library.
Encrypt your secret using the [libsodium-wrappers](https://www.npmjs.com/package/libsodium-wrappers) library.

```
const sodium = require('tweetsodium');
const sodium = require('libsodium-wrappers')
const secret = 'plain-text-secret' // replace with the secret you want to encrypt
const key = 'base64-encoded-public-key' // replace with the Base64 encoded public key

const key = "base64-encoded-public-key";
const value = "plain-text-secret";
//Check if libsodium is ready and then proceed.
sodium.ready.then(() => {
// Convert Secret & Base64 key to Uint8Array.
let binkey = sodium.from_base64(key, sodium.base64_variants.ORIGINAL)
let binsec = sodium.from_string(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 the secret using LibSodium
let encBytes = sodium.crypto_box_seal(binsec, binkey)

// Encrypt using LibSodium.
const encryptedBytes = sodium.seal(messageBytes, keyBytes);
// Convert encrypted Uint8Array to Base64
let output = sodium.to_base64(encBytes, sodium.base64_variants.ORIGINAL)

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

console.log(encrypted);
console.log(output)
});
```

#### Example encrypting a secret using Python
Expand Down
63 changes: 63 additions & 0 deletions docs/actions/createOrgVariable.md
@@ -0,0 +1,63 @@
---
name: Create an organization variable
example: octokit.rest.actions.createOrgVariable({ org, name, value, visibility })
route: POST /orgs/{org}/actions/variables
scope: actions
type: API method
---

# Create an organization variable

Creates an organization variable that you can reference in a GitHub Actions workflow.
You must authenticate using an access token with the `admin:org` scope to use this endpoint.
GitHub Apps must have the `organization_actions_variables:write` organization permission to use this endpoint.

```js
octokit.rest.actions.createOrgVariable({
org,
name,
value,
visibility,
});
```

## Parameters

<table>
<thead>
<tr>
<th>name</th>
<th>required</th>
<th>description</th>
</tr>
</thead>
<tbody>
<tr><td>org</td><td>yes</td><td>

The organization name. The name is not case sensitive.

</td></tr>
<tr><td>name</td><td>yes</td><td>

The name of the variable.

</td></tr>
<tr><td>value</td><td>yes</td><td>

The value of the variable.

</td></tr>
<tr><td>visibility</td><td>yes</td><td>

The type of repositories in the organization that can access the variable. `selected` means only the repositories specified by `selected_repository_ids` can access the variable.

</td></tr>
<tr><td>selected_repository_ids</td><td>no</td><td>

An array of repository ids that can access the organization variable. You can only provide a list of repository ids when the `visibility` is set to `selected`.

</td></tr>
</tbody>
</table>

See also: [GitHub Developer Guide documentation](https://docs.github.com/rest/actions/variables#create-an-organization-variable).
58 changes: 58 additions & 0 deletions docs/actions/createRepoVariable.md
@@ -0,0 +1,58 @@
---
name: Create a repository variable
example: octokit.rest.actions.createRepoVariable({ owner, repo, name, value })
route: POST /repos/{owner}/{repo}/actions/variables
scope: actions
type: API method
---

# Create a repository variable

Creates a repository variable that you can reference in a GitHub Actions workflow.
You must authenticate using an access token with the `repo` scope to use this endpoint.
GitHub Apps must have the `actions_variables:write` repository permission to use this endpoint.

```js
octokit.rest.actions.createRepoVariable({
owner,
repo,
name,
value,
});
```

## Parameters

<table>
<thead>
<tr>
<th>name</th>
<th>required</th>
<th>description</th>
</tr>
</thead>
<tbody>
<tr><td>owner</td><td>yes</td><td>

The account owner of the repository. The name is not case sensitive.

</td></tr>
<tr><td>repo</td><td>yes</td><td>

The name of the repository. The name is not case sensitive.

</td></tr>
<tr><td>name</td><td>yes</td><td>

The name of the variable.

</td></tr>
<tr><td>value</td><td>yes</td><td>

The value of the variable.

</td></tr>
</tbody>
</table>

See also: [GitHub Developer Guide documentation](https://docs.github.com/rest/actions/variables#create-a-repository-variable).