Skip to content

Commit

Permalink
docs: metion setting media type to support previews (#215)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremycarroll committed Apr 26, 2023
1 parent 8cc86c5 commit 02863ff
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,28 @@ jobs:
}
}
mediaType: '{"previews": ["packages"]}'
- run: "echo packages: '${{ steps.test_with_mediaType_previews.outputs.data }}'"
- id: test_with_mediaType_previews_yaml
uses: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
query: |
query pullRequest(
$repo:String!
$owner:String!) {
repository(name:$repo, owner:$owner) {
pullRequests(last:1) {
nodes {
number
mergeStateStatus
}
}
}
}
owner: ${{ github.event.repository.owner.name }}
repo: ${{ github.event.repository.name }}
mediaType: |
previews:
- merge-info
- run: "echo merge state status: '${{ steps.test_with_mediaType_previews_yaml.outputs.data }}'"
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,34 @@ that requests are automatically authenticated using the `GITHUB_TOKEN` environme

The actions sets `data` output to the response data. Note that it is a string, you should use [`fromJSON()`](https://docs.github.com/en/actions/learn-github-actions/expressions#fromjson) to access any value of the response. The action also sets `headers` (again, to a JSON string) and `status`.

## Preview Media Types

New features of graphql require the use of an Accept header with a preview media-type.
This is supported with a `mediaType` property, e.g.
```yml
steps:
- uses: octokit/graphql-action@v2.x
with:
query: |
query pullRequest(
$repo:String!
$owner:String!) {
repository(name:$repo, owner:$owner) {
pullRequests(last:1) {
nodes {
number
mergeStateStatus
}
}
}
}
owner: ${{ github.event.repository.owner.name }}
repo: ${{ github.event.repository.name }}
mediaType: |
previews:
- merge-info
```

## Troubleshooting

### Input variables
Expand Down
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ inputs:
query:
description: "Your GraphQL query, see https://developer.github.com/v4/"
required: true
mediaType:
description: "Enable previews - see https://github.com/octokit/graphql-action/blob/main/README.md#preview-media-types"
outputs:
data:
description: 'The "data" key of the GraphQL response body'
Expand Down

0 comments on commit 02863ff

Please sign in to comment.