Skip to content

Commit 2e0d2f3

Browse files
Add GitHub Models in Actions docs (#55174)
Co-authored-by: Sophie <[email protected]>
1 parent fe94f48 commit 2e0d2f3

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

content/github-models/integrating-ai-models-into-your-development-workflow.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,47 @@ If you have a {% data variables.product.prodname_copilot_short %} subscription,
3030
* Executing prompts using a particular model. This is especially useful when you want to use a model that is not currently available in multi-model {% data variables.product.prodname_copilot_chat_short %}.
3131
* Listing models currently available through {% data variables.product.prodname_github_models %}
3232

33+
## Using AI models with {% data variables.product.prodname_actions %}
34+
35+
You can use the {% data variables.product.prodname_actions %} token (`GITHUB_TOKEN`) to call AI models directly inside your workflows.
36+
37+
### Setting permissions
38+
39+
To use AI models in your workflows, you need to ensure that the `models` permission is enabled in your workflow configuration. This permission allows workflows to access the {% data variables.product.prodname_github_models %} inference API. You can either set this permission itself or use the general `read-all` or `write-all` permissions. See [AUTOTITLE](/rest/overview/permissions-required-for-github-apps?apiVersion=2022-11-28#repository-permissions-for-actions).
40+
41+
### Writing your workflow file
42+
43+
You can call the inference API directly from your workflow. For instance:
44+
45+
```yaml
46+
name: Use GitHub Models
47+
48+
on:
49+
workflow_dispatch:
50+
51+
permissions:
52+
models: read
53+
54+
jobs:
55+
call-model:
56+
runs-on: ubuntu-latest
57+
steps:
58+
- name: Call AI model
59+
run: |
60+
curl -X POST "https://models.inference.ai.azure.com/chat/completions" \
61+
-H "Content-Type: application/json" \
62+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
63+
-d '{
64+
"messages": [
65+
{
66+
"role": "user",
67+
"content": "Explain the concept of recursion."
68+
}
69+
],
70+
"model": "gpt-4o"
71+
}'
72+
```
73+
3374
## Using AI models from the command line
3475
3576
> [!NOTE] The {% data variables.product.prodname_github_models %} extension for {% data variables.product.prodname_cli %} is in {% data variables.release-phases.public_preview %} and is subject to change.

data/reusables/actions/github-token-available-permissions.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ permissions:
88
contents: read|write|none
99
deployments: read|write|none{% ifversion fpt or ghec %}
1010
id-token: write|none{% endif %}
11-
issues: read|write|none
11+
issues: read|write|none{% ifversion not ghes %}
12+
models: read|none{% endif %}
1213
discussions: read|write|none
1314
packages: read|write|none
1415
pages: read|write|none

data/reusables/actions/github-token-scope-descriptions.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ Available permissions and details of what each allows an action to do:
1616
| `id-token` | Fetch an OpenID Connect (OIDC) token. This requires `id-token: write`. For more information, see [AUTOTITLE](/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect#updating-your-actions-for-oidc) |
1717
| {% endif %} |
1818
| `issues` | Work with issues. For example, `issues: write` permits an action to add a comment to an issue. For more information, see [AUTOTITLE](/rest/overview/permissions-required-for-github-apps?apiVersion=2022-11-28#repository-permissions-for-issues). |
19+
| {% ifversion not ghes %} |
20+
| `models` | Generate AI inference responses with {% data variables.product.prodname_github_models %}. For example, `models: read` permits an action to use the {% data variables.product.prodname_github_models %} inference API. See [AUTOTITLE](/github-models/prototyping-with-ai-models). |
21+
| {% endif %} |
1922
| `packages` | Work with GitHub Packages. For example, `packages: write` permits an action to upload and publish packages on GitHub Packages. For more information, see [AUTOTITLE](/packages/learn-github-packages/about-permissions-for-github-packages#about-scopes-and-permissions-for-package-registries). |
2023
| `pages` | Work with GitHub Pages. For example, `pages: write` permits an action to request a GitHub Pages build. For more information, see [AUTOTITLE](/rest/overview/permissions-required-for-github-apps?apiVersion=2022-11-28#repository-permissions-for-pages). |
2124
| `pull-requests` | Work with pull requests. For example, `pull-requests: write` permits an action to add a label to a pull request. For more information, see [AUTOTITLE](/rest/overview/permissions-required-for-github-apps?apiVersion=2022-11-28#repository-permissions-for-pull-requests). |

0 commit comments

Comments
 (0)