Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e977bce

Browse files
authored
Combine product name variables for REST and GraphQL API base URLs (#50521)
1 parent aef6bc2 commit e977bce

40 files changed

Lines changed: 99 additions & 107 deletions

File tree

content/actions/deployment/protecting-deployments/creating-custom-deployment-protection-rules.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Once a workflow reaches a job that references an environment that has the custom
5757

5858
```shell
5959
curl --request POST \
60-
--url "{% data variables.product.api_url_code %}/app/installations/INSTALLATION_ID/ACCESS_TOKENS" \
60+
--url "{% data variables.product.rest_url %}/app/installations/INSTALLATION_ID/ACCESS_TOKENS" \
6161
--header "Accept: application/vnd.github+json" \
6262
--header "Authorization: Bearer {jwt}" \
6363
--header "Content-Type: application/json" \

content/actions/learn-github-actions/variables.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,12 +278,12 @@ We strongly recommend that actions use variables to access the filesystem rather
278278
{%- ifversion actions-oidc-custom-claims %}
279279
| `GITHUB_ACTOR_ID` | {% data reusables.actions.actor_id-description %} |
280280
{%- endif %}
281-
| `GITHUB_API_URL` | Returns the API URL. For example: `{% data variables.product.api_url_code %}`.
281+
| `GITHUB_API_URL` | Returns the API URL. For example: `{% data variables.product.rest_url %}`.
282282
| `GITHUB_BASE_REF` | The name of the base ref or target branch of the pull request in a workflow run. This is only set when the event that triggers a workflow run is either `pull_request` or `pull_request_target`. For example, `main`. |
283283
| `GITHUB_ENV` | The path on the runner to the file that sets variables from workflow commands. The path to this file is unique to the current step and changes for each step in a job. For example, `/home/runner/work/_temp/_runner_file_commands/set_env_87406d6e-4979-4d42-98e1-3dab1f48b13a`. For more information, see "[AUTOTITLE](/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable)." |
284284
| `GITHUB_EVENT_NAME` | The name of the event that triggered the workflow. For example, `workflow_dispatch`. |
285285
| `GITHUB_EVENT_PATH` | The path to the file on the runner that contains the full event webhook payload. For example, `/github/workflow/event.json`. |
286-
| `GITHUB_GRAPHQL_URL` | Returns the GraphQL API URL. For example: `{% data variables.product.graphql_url_code %}`.
286+
| `GITHUB_GRAPHQL_URL` | Returns the GraphQL API URL. For example: `{% data variables.product.graphql_url %}`.
287287
| `GITHUB_HEAD_REF` | The head ref or source branch of the pull request in a workflow run. This property is only set when the event that triggers a workflow run is either `pull_request` or `pull_request_target`. For example, `feature-branch-1`. |
288288
| `GITHUB_JOB` | The [job_id](/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_id) of the current job. For example, `greeting_job`. |
289289
| `GITHUB_OUTPUT` | The path on the runner to the file that sets the current step's outputs from workflow commands. The path to this file is unique to the current step and changes for each step in a job. For example, `/home/runner/work/_temp/_runner_file_commands/set_output_a50ef383-b063-46d9-9157-57953fc9f3f0`. For more information, see "[AUTOTITLE](/actions/using-workflows/workflow-commands-for-github-actions#setting-an-output-parameter)." |

content/actions/security-guides/automatic-token-authentication.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
- name: Create issue using REST API
6262
run: |
6363
curl --request POST \
64-
--url {% data variables.product.api_url_code %}/repos/${% raw %}{{ github.repository }}{% endraw %}/issues \
64+
--url {% data variables.product.rest_url %}/repos/${% raw %}{{ github.repository }}{% endraw %}/issues \
6565
--header 'authorization: Bearer ${% raw %}{{ secrets.GITHUB_TOKEN }}{% endraw %}' \
6666
--header 'content-type: application/json' \
6767
--data '{

content/admin/monitoring-activity-in-your-enterprise/reviewing-audit-logs-for-your-enterprise/using-the-audit-log-api-for-your-enterprise.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ The query below searches for audit log events created on Jan 1st, 2022 in the `a
4949
```shell
5050
curl -H "Authorization: Bearer TOKEN" \
5151
--request GET \
52-
"{% data variables.product.api_url_code %}/enterprises/avocado-corp/audit-log?phrase=created:2022-01-01&page=1&per_page=100"
52+
"{% data variables.product.rest_url %}/enterprises/avocado-corp/audit-log?phrase=created:2022-01-01&page=1&per_page=100"
5353
```
5454

5555
{% else %}
@@ -59,23 +59,23 @@ The query below searches for audit log events created on Jan 1st, 2022 in the `a
5959
```shell
6060
curl --include -H "Authorization: Bearer TOKEN" \
6161
--request GET \
62-
"{% data variables.product.api_url_code %}/enterprises/avocado-corp/audit-log?phrase=created:2022-01-01&per_page=100"
62+
"{% data variables.product.rest_url %}/enterprises/avocado-corp/audit-log?phrase=created:2022-01-01&per_page=100"
6363
```
6464

6565
If there are more than 100 results, the `link` header will include URLs to fetch the next, first, and previous pages of results.
6666

6767
```text
68-
link: <{% data variables.product.api_url_code %}/enterprises/13827/audit-log?%3A2022-11-01=&per_page=100&after=MS42NjQzODMzNTk5MjdlKzEyfDloQzBxdURzaFdVbVlLWjkxRU9mNXc%3D&before=>; rel="next",
69-
<{% data variables.product.api_url_code %}/enterprises/13827/audit-log?%3A2022-11-01=&per_page=100&after=&before=>; rel="first",
70-
<{% data variables.product.api_url_code %}/enterprises/13827/audit-log?%3A2022-11-01=&per_page=100&after=&before=MS42Njc4NDA2MjM4MzNlKzEyfExqeG5sUElvNEZMbG1XZHA5akdKTVE%3D>; rel="prev"
68+
link: <{% data variables.product.rest_url %}/enterprises/13827/audit-log?%3A2022-11-01=&per_page=100&after=MS42NjQzODMzNTk5MjdlKzEyfDloQzBxdURzaFdVbVlLWjkxRU9mNXc%3D&before=>; rel="next",
69+
<{% data variables.product.rest_url %}/enterprises/13827/audit-log?%3A2022-11-01=&per_page=100&after=&before=>; rel="first",
70+
<{% data variables.product.rest_url %}/enterprises/13827/audit-log?%3A2022-11-01=&per_page=100&after=&before=MS42Njc4NDA2MjM4MzNlKzEyfExqeG5sUElvNEZMbG1XZHA5akdKTVE%3D>; rel="prev"
7171
```
7272

7373
Copy the corresponding pagination link into your next request. For example:
7474

7575
```shell
7676
curl -I -H "Authorization: Bearer TOKEN" \
7777
--request GET \
78-
"{% data variables.product.api_url_code %}/enterprises/13827/audit-log?%3A2022-11-01=&per_page=100&after=MS42Njc4NDA2MjM5NDFlKzEyfHRYa3AwSkxUd2xyRjA5bWxfOS1RbFE%3D&before="
78+
"{% data variables.product.rest_url %}/enterprises/13827/audit-log?%3A2022-11-01=&per_page=100&after=MS42Njc4NDA2MjM5NDFlKzEyfHRYa3AwSkxUd2xyRjA5bWxfOS1RbFE%3D&before="
7979
```
8080

8181
{% endif %}
@@ -89,7 +89,7 @@ The query below searches for audit log events for pull requests, where the event
8989
```shell
9090
curl -H "Authorization: Bearer TOKEN" \
9191
--request GET \
92-
"{% data variables.product.api_url_code %}/enterprises/avocado-corp/audit-log?phrase=action:pull_request+created:>=2022-01-01+actor:octocat"
92+
"{% data variables.product.rest_url %}/enterprises/avocado-corp/audit-log?phrase=action:pull_request+created:>=2022-01-01+actor:octocat"
9393
```
9494

9595
## Example 3: Events for Git activity in an enterprise, for a specific date and actor
@@ -101,5 +101,5 @@ The query below searches for audit log events for Git activity, where the event
101101
```shell
102102
curl -H "Authorization: Bearer TOKEN" \
103103
--request GET \
104-
"{% data variables.product.api_url_code %}/enterprises/avocado-corp/audit-log?phrase=created:>=2024-01-01+actor:octocat&include=git"
104+
"{% data variables.product.rest_url %}/enterprises/avocado-corp/audit-log?phrase=created:>=2024-01-01+actor:octocat&include=git"
105105
```

content/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-as-a-github-app-installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ In the following example, replace `INSTALLATION_ACCESS_TOKEN` with an installati
4646

4747
```shell
4848
curl --request GET \
49-
--url "{% data variables.product.api_url_pre %}/meta" \
49+
--url "{% data variables.product.rest_url %}/meta" \
5050
--header "Accept: application/vnd.github+json" \
5151
--header "Authorization: Bearer INSTALLATION_ACCESS_TOKEN" \
5252
--header "X-GitHub-Api-Version: {{ allVersions[currentVersion].latestApiVersion }}"

content/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-as-a-github-app.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ If a REST API endpoint requires you to authenticate as an app, the documentation
2323

2424
```shell
2525
curl --request GET \
26-
--url "{% data variables.product.api_url_pre %}/app/installations" \
26+
--url "{% data variables.product.rest_url %}/app/installations" \
2727
--header "Accept: application/vnd.github+json" \
2828
--header "Authorization: Bearer YOUR_JWT" \
2929
--header "X-GitHub-Api-Version: {{ allVersions[currentVersion].latestApiVersion }}"

content/apps/creating-github-apps/authenticating-with-a-github-app/generating-a-json-web-token-jwt-for-a-github-app.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ To use a JWT, pass it in the `Authorization` header of an API request. For examp
2727

2828
```shell
2929
curl --request GET \
30-
--url "{% data variables.product.api_url_pre %}/app" \
30+
--url "{% data variables.product.rest_url %}/app" \
3131
--header "Accept: application/vnd.github+json" \
3232
--header "Authorization: Bearer YOUR_JWT" \
3333
--header "X-GitHub-Api-Version: {{ allVersions[currentVersion].latestApiVersion }}"
@@ -128,7 +128,7 @@ payload = {
128128
# {% data variables.product.prodname_github_app %}'s client ID
129129
'iss': client_id{% else %}
130130
# {% data variables.product.prodname_github_app %}'s app ID
131-
'iss': app_id{% endif %}
131+
'iss': app_id{% endif %}
132132
}
133133

134134
# Create JWT
@@ -156,7 +156,7 @@ set -o pipefail
156156
client_id=$1 # Client ID as first argument
157157
{% else %}
158158
app_id=$1 # App ID as first argument
159-
{% endif %}
159+
{% endif %}
160160
pem=$( cat $2 ) # file path of the private key as second argument
161161

162162
now=$(date +%s)
@@ -175,7 +175,7 @@ header=$( echo -n "${header_json}" | b64enc )
175175
payload_json='{
176176
"iat":'"${iat}"',
177177
"exp":'"${exp}"',
178-
{% ifversion client-id-for-app %}"iss":'"${client_id}"'{% else %}"iss":'"${client_id}"'{% endif %}
178+
{% ifversion client-id-for-app %}"iss":'"${client_id}"'{% else %}"iss":'"${client_id}"'{% endif %}
179179
}'
180180
# Payload encode
181181
payload=$( echo -n "${payload_json}" | b64enc )
@@ -203,7 +203,7 @@ In the following example, replace `YOUR_PATH_TO_PEM` with the file path where yo
203203
$client_id = YOUR_CLIENT_ID
204204
{% else %}
205205
$app_id = YOUR_APP_ID
206-
{% endif %}
206+
{% endif %}
207207
$private_key_path = "YOUR_PATH_TO_PEM"
208208

209209
$header = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes((ConvertTo-Json -InputObject @{
@@ -214,7 +214,7 @@ $header = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes((Conve
214214
$payload = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes((ConvertTo-Json -InputObject @{
215215
iat = [System.DateTimeOffset]::UtcNow.AddSeconds(-10).ToUnixTimeSeconds()
216216
exp = [System.DateTimeOffset]::UtcNow.AddMinutes(10).ToUnixTimeSeconds()
217-
{% ifversion client-id-for-app %} iss = $client_id{% else %} iss = $app_id{% endif %}
217+
{% ifversion client-id-for-app %} iss = $client_id{% else %} iss = $app_id{% endif %}
218218
}))).TrimEnd('=').Replace('+', '-').Replace('/', '_');
219219

220220
$rsa = [System.Security.Cryptography.RSA]::Create()

content/apps/creating-github-apps/writing-code-for-a-github-app/building-a-cli-with-a-github-app.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ Now that your app can generate a user access token, you can make API requests on
490490

491491
```ruby copy
492492
def whoami
493-
uri = URI("{% data variables.product.api_url_code %}/user")
493+
uri = URI("{% data variables.product.rest_url %}/user")
494494
495495
begin
496496
token = File.read("./.token").strip
@@ -675,7 +675,7 @@ This is the full code example that was outlined in the previous section. Replace
675675
end
676676
677677
def whoami
678-
uri = URI("{% data variables.product.api_url_code %}/user")
678+
uri = URI("{% data variables.product.rest_url %}/user")
679679
680680
begin
681681
token = File.read("./.token").strip

content/apps/creating-github-apps/writing-code-for-a-github-app/building-a-login-with-github-button-with-a-github-app.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ These steps lead you through writing code to generate a user access token. To sk
249249

250250
```ruby copy
251251
def user_info(token)
252-
uri = URI("{% data variables.product.api_url_code %}/user")
252+
uri = URI("{% data variables.product.rest_url %}/user")
253253

254254
result = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
255255
body = {"access_token" => token}.to_json
@@ -332,7 +332,7 @@ def exchange_code(code)
332332
end
333333

334334
def user_info(token)
335-
uri = URI("{% data variables.product.api_url_code %}/user")
335+
uri = URI("{% data variables.product.rest_url %}/user")
336336

337337
result = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
338338
body = {"access_token" => token}.to_json

content/apps/oauth-apps/building-oauth-apps/authenticating-to-the-rest-api-with-an-oauth-app.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,13 @@ the logged in user:
182182

183183
``` ruby
184184
# fetch user information
185-
auth_result = JSON.parse(RestClient.get('{% data variables.product.api_url_code %}/user',
185+
auth_result = JSON.parse(RestClient.get('{% data variables.product.rest_url %}/user',
186186
{:params => {:access_token => access_token}}))
187187

188188
# if the user authorized it, fetch private emails
189189
if has_user_email_scope
190190
auth_result['private_emails'] =
191-
JSON.parse(RestClient.get('{% data variables.product.api_url_code %}/user/emails',
191+
JSON.parse(RestClient.get('{% data variables.product.rest_url %}/user/emails',
192192
{:params => {:access_token => access_token}}))
193193
end
194194

@@ -271,7 +271,7 @@ get '/' do
271271
scopes = []
272272

273273
begin
274-
auth_result = RestClient.get('{% data variables.product.api_url_code %}/user',
274+
auth_result = RestClient.get('{% data variables.product.rest_url %}/user',
275275
{:params => {:access_token => access_token},
276276
:accept => :json})
277277
rescue => e
@@ -292,7 +292,7 @@ get '/' do
292292

293293
if scopes.include? 'user:email'
294294
auth_result['private_emails'] =
295-
JSON.parse(RestClient.get('{% data variables.product.api_url_code %}/user/emails',
295+
JSON.parse(RestClient.get('{% data variables.product.rest_url %}/user/emails',
296296
{:params => {:access_token => access_token},
297297
:accept => :json}))
298298
end

0 commit comments

Comments
 (0)