Update all articles where GITHUB_TOKEN should appear as GH_TOKEN (#30770)
Co-authored-by: Sarah Edwards <skedwards88@github.com>
This commit is contained in:
@@ -46,14 +46,14 @@ In the tutorial, you will first make a workflow file that uses the {% data varia
|
|||||||
steps:
|
steps:
|
||||||
- run: gh issue edit "$NUMBER" --add-label "$LABELS"
|
- run: gh issue edit "$NUMBER" --add-label "$LABELS"
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
|
GH_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
|
||||||
GH_REPO: {% raw %}${{ github.repository }}{% endraw %}
|
GH_REPO: {% raw %}${{ github.repository }}{% endraw %}
|
||||||
NUMBER: {% raw %}${{ github.event.issue.number }}{% endraw %}
|
NUMBER: {% raw %}${{ github.event.issue.number }}{% endraw %}
|
||||||
LABELS: triage
|
LABELS: triage
|
||||||
```
|
```
|
||||||
|
|
||||||
1. Customize the `env` values in your workflow file:
|
1. Customize the `env` values in your workflow file:
|
||||||
- The `GITHUB_TOKEN`, `GH_REPO`, and `NUMBER` values are automatically set using the `github` and `secrets` contexts. You do not need to change these.
|
- The `GH_TOKEN`, `GH_REPO`, and `NUMBER` values are automatically set using the `github` and `secrets` contexts. You do not need to change these.
|
||||||
- Change the value for `LABELS` to the list of labels that you want to add to the issue. The label(s) must exist for your repository. Separate multiple labels with commas. For example, `help wanted,good first issue`. For more information about labels, see "[AUTOTITLE](/issues/using-labels-and-milestones-to-track-work/managing-labels#applying-labels-to-issues-and-pull-requests)."
|
- Change the value for `LABELS` to the list of labels that you want to add to the issue. The label(s) must exist for your repository. Separate multiple labels with commas. For example, `help wanted,good first issue`. For more information about labels, see "[AUTOTITLE](/issues/using-labels-and-milestones-to-track-work/managing-labels#applying-labels-to-issues-and-pull-requests)."
|
||||||
1. {% data reusables.actions.commit-workflow %}
|
1. {% data reusables.actions.commit-workflow %}
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ In the tutorial, you will first make a workflow file that uses the `gh issue com
|
|||||||
- name: Add comment
|
- name: Add comment
|
||||||
run: gh issue comment "$NUMBER" --body "$BODY"
|
run: gh issue comment "$NUMBER" --body "$BODY"
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
|
GH_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
|
||||||
GH_REPO: {% raw %}${{ github.repository }}{% endraw %}
|
GH_REPO: {% raw %}${{ github.repository }}{% endraw %}
|
||||||
NUMBER: {% raw %}${{ github.event.issue.number }}{% endraw %}
|
NUMBER: {% raw %}${{ github.event.issue.number }}{% endraw %}
|
||||||
BODY: >
|
BODY: >
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ In the tutorial, you will first make a workflow file that uses the {% data varia
|
|||||||
gh issue pin "$new_issue_url"
|
gh issue pin "$new_issue_url"
|
||||||
fi
|
fi
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
|
GH_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
|
||||||
GH_REPO: {% raw %}${{ github.repository }}{% endraw %}
|
GH_REPO: {% raw %}${{ github.repository }}{% endraw %}
|
||||||
TITLE: Team sync
|
TITLE: Team sync
|
||||||
ASSIGNEES: monalisa,doctocat,hubot
|
ASSIGNEES: monalisa,doctocat,hubot
|
||||||
|
|||||||
@@ -53,13 +53,13 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- env:
|
- env:
|
||||||
GITHUB_TOKEN: {% raw %}${{ secrets.MY_TOKEN }}{% endraw %}
|
GH_TOKEN: {% raw %}${{ secrets.MY_TOKEN }}{% endraw %}
|
||||||
ISSUE_URL: {% raw %}${{ github.event.issue.html_url }}{% endraw %}
|
ISSUE_URL: {% raw %}${{ github.event.issue.html_url }}{% endraw %}
|
||||||
run: |
|
run: |
|
||||||
gh issue edit $ISSUE_URL --add-label "triage"
|
gh issue edit $ISSUE_URL --add-label "triage"
|
||||||
```
|
```
|
||||||
|
|
||||||
Conversely, the following workflow uses `GITHUB_TOKEN` to add a label to an issue. It will not trigger any workflows that run when a label is added.
|
Conversely, the following workflow uses `GITHUB_TOKEN ` to add a label to an issue. It will not trigger any workflows that run when a label is added.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
on:
|
on:
|
||||||
@@ -72,7 +72,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- env:
|
- env:
|
||||||
GITHUB_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
|
GH_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
|
||||||
ISSUE_URL: {% raw %}${{ github.event.issue.html_url }}{% endraw %}
|
ISSUE_URL: {% raw %}${{ github.event.issue.html_url }}{% endraw %}
|
||||||
run: |
|
run: |
|
||||||
gh issue edit $ISSUE_URL --add-label "triage"
|
gh issue edit $ISSUE_URL --add-label "triage"
|
||||||
@@ -172,7 +172,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: "Comment about changes we can't accept"
|
- name: "Comment about changes we can't accept"
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
|
GH_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
|
||||||
PR: {% raw %}${{ github.event.pull_request.html_url }}{% endraw %}
|
PR: {% raw %}${{ github.event.pull_request.html_url }}{% endraw %}
|
||||||
run: |
|
run: |
|
||||||
gh pr edit $PR --add-label 'invalid'
|
gh pr edit $PR --add-label 'invalid'
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ type: how_to
|
|||||||
|
|
||||||
{% data reusables.cli.cli-learn-more %}
|
{% data reusables.cli.cli-learn-more %}
|
||||||
|
|
||||||
{% data variables.product.prodname_cli %} is preinstalled on all {% data variables.product.prodname_dotcom %}-hosted runners. For each step that uses {% data variables.product.prodname_cli %}, you must set an environment variable called `GITHUB_TOKEN` to a token with the required scopes.
|
{% data variables.product.prodname_cli %} is preinstalled on all {% data variables.product.prodname_dotcom %}-hosted runners. For each step that uses {% data variables.product.prodname_cli %}, you must set an environment variable called `GH_TOKEN` to a token with the required scopes.
|
||||||
|
|
||||||
You can execute any {% data variables.product.prodname_cli %} command. For example, this workflow uses the `gh issue comment` subcommand to add a comment when an issue is opened.
|
You can execute any {% data variables.product.prodname_cli %} command. For example, this workflow uses the `gh issue comment` subcommand to add a comment when an issue is opened.
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- run: gh issue comment $ISSUE --body "Thank you for opening this issue!"
|
- run: gh issue comment $ISSUE --body "Thank you for opening this issue!"
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
|
GH_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
|
||||||
ISSUE: {% raw %}${{ github.event.issue.html_url }}{% endraw %}
|
ISSUE: {% raw %}${{ github.event.issue.html_url }}{% endraw %}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -64,11 +64,11 @@ jobs:
|
|||||||
|
|
||||||
echo 'NUM_OPEN_ISSUES='$numOpenIssues >> $GITHUB_ENV
|
echo 'NUM_OPEN_ISSUES='$numOpenIssues >> $GITHUB_ENV
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
|
GH_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
|
||||||
OWNER: {% raw %}${{ github.repository_owner }}{% endraw %}
|
OWNER: {% raw %}${{ github.repository_owner }}{% endraw %}
|
||||||
REPO: {% raw %}${{ github.event.repository.name }}{% endraw %}
|
REPO: {% raw %}${{ github.event.repository.name }}{% endraw %}
|
||||||
- run: |
|
- run: |
|
||||||
gh issue create --title "Issue report" --body "$NUM_OPEN_ISSUES issues remaining" --repo $GITHUB_REPOSITORY
|
gh issue create --title "Issue report" --body "$NUM_OPEN_ISSUES issues remaining" --repo $GITHUB_REPOSITORY
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
|
GH_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Use the token
|
- name: Use the token
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: {% raw %}${{ steps.generate_token.outputs.token }}{% endraw %}
|
GH_TOKEN: {% raw %}${{ steps.generate_token.outputs.token }}{% endraw %}
|
||||||
run: |
|
run: |
|
||||||
gh api octocat
|
gh api octocat
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -222,7 +222,7 @@ jobs:
|
|||||||
run: gh pr review --approve "$PR_URL"
|
run: gh pr review --approve "$PR_URL"
|
||||||
env:
|
env:
|
||||||
PR_URL: ${{github.event.pull_request.html_url}}
|
PR_URL: ${{github.event.pull_request.html_url}}
|
||||||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
||||||
```
|
```
|
||||||
|
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
@@ -266,7 +266,7 @@ jobs:
|
|||||||
run: gh pr merge --auto --merge "$PR_URL"
|
run: gh pr merge --auto --merge "$PR_URL"
|
||||||
env:
|
env:
|
||||||
PR_URL: ${{github.event.pull_request.html_url}}
|
PR_URL: ${{github.event.pull_request.html_url}}
|
||||||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
||||||
```
|
```
|
||||||
|
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- run: gh pr comment $PR_URL --body "Welcome to the repository!"
|
- run: gh pr comment $PR_URL --body "Welcome to the repository!"
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
PR_URL: ${{ github.event.pull_request.html_url }}
|
PR_URL: ${{ github.event.pull_request.html_url }}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -117,6 +117,6 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- run: gh pr comment $PR_URL --body "Welcome to the repository!"
|
- run: gh pr comment $PR_URL --body "Welcome to the repository!"
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
PR_URL: ${{ github.event.pull_request.html_url }}
|
PR_URL: ${{ github.event.pull_request.html_url }}
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ Code annotations only work in articles with the `layout: inline` frontmatter pro
|
|||||||
steps:
|
steps:
|
||||||
- run: gh pr comment $PR_URL --body "Welcome to the repository!"
|
- run: gh pr comment $PR_URL --body "Welcome to the repository!"
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
PR_URL: ${{ github.event.pull_request.html_url }}
|
PR_URL: ${{ github.event.pull_request.html_url }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ jobs:
|
|||||||
# Replace `YOUR_PROJECT_NUMBER` with your project number. To find the project number, look at the project URL. For example, `https://github.com/orgs/octo-org/projects/5` has a project number of 5.
|
# Replace `YOUR_PROJECT_NUMBER` with your project number. To find the project number, look at the project URL. For example, `https://github.com/orgs/octo-org/projects/5` has a project number of 5.
|
||||||
- name: Get project data
|
- name: Get project data
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: {% raw %}${{ steps.generate_token.outputs.token }}{% endraw %}
|
GH_TOKEN: {% raw %}${{ steps.generate_token.outputs.token }}{% endraw %}
|
||||||
ORGANIZATION: YOUR_ORGANIZATION
|
ORGANIZATION: YOUR_ORGANIZATION
|
||||||
PROJECT_NUMBER: YOUR_PROJECT_NUMBER
|
PROJECT_NUMBER: YOUR_PROJECT_NUMBER
|
||||||
# Uses [{% data variables.product.prodname_cli %}](https://cli.github.com/manual/) to query the API for the ID of the project and return the name and ID of the first 20 fields in the project. `fields` returns a union and the query uses inline fragments (`... on`) to return information about any `ProjectV2Field` and `ProjectV2SingleSelectField` fields. The response is stored in a file called `project_data.json`.
|
# Uses [{% data variables.product.prodname_cli %}](https://cli.github.com/manual/) to query the API for the ID of the project and return the name and ID of the first 20 fields in the project. `fields` returns a union and the query uses inline fragments (`... on`) to return information about any `ProjectV2Field` and `ProjectV2SingleSelectField` fields. The response is stored in a file called `project_data.json`.
|
||||||
@@ -132,10 +132,10 @@ jobs:
|
|||||||
echo 'STATUS_FIELD_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Status") | .id' project_data.json) >> $GITHUB_ENV
|
echo 'STATUS_FIELD_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Status") | .id' project_data.json) >> $GITHUB_ENV
|
||||||
echo 'TODO_OPTION_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Status") | .options[] | select(.name=="Todo") |.id' project_data.json) >> $GITHUB_ENV
|
echo 'TODO_OPTION_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Status") | .options[] | select(.name=="Todo") |.id' project_data.json) >> $GITHUB_ENV
|
||||||
|
|
||||||
# Sets environment variables for this step. `GITHUB_TOKEN` is the token generated in the first step. `PR_ID` is the ID of the pull request that triggered this workflow.
|
# Sets environment variables for this step. `GH_TOKEN` is the token generated in the first step. `PR_ID` is the ID of the pull request that triggered this workflow.
|
||||||
- name: Add PR to project
|
- name: Add PR to project
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: {% raw %}${{ steps.generate_token.outputs.token }}{% endraw %}
|
GH_TOKEN: {% raw %}${{ steps.generate_token.outputs.token }}{% endraw %}
|
||||||
PR_ID: {% raw %}${{ github.event.pull_request.node_id }}{% endraw %}
|
PR_ID: {% raw %}${{ github.event.pull_request.node_id }}{% endraw %}
|
||||||
# Uses [{% data variables.product.prodname_cli %}](https://cli.github.com/manual/) and the API to add the pull request that triggered this workflow to the project. The `jq` flag parses the response to get the ID of the created item.
|
# Uses [{% data variables.product.prodname_cli %}](https://cli.github.com/manual/) and the API to add the pull request that triggered this workflow to the project. The `jq` flag parses the response to get the ID of the created item.
|
||||||
run: |
|
run: |
|
||||||
@@ -155,10 +155,10 @@ jobs:
|
|||||||
- name: Get date
|
- name: Get date
|
||||||
run: echo "DATE=$(date +"%Y-%m-%d")" >> $GITHUB_ENV
|
run: echo "DATE=$(date +"%Y-%m-%d")" >> $GITHUB_ENV
|
||||||
|
|
||||||
# Sets environment variables for this step. `GITHUB_TOKEN` is the token generated in the first step.
|
# Sets environment variables for this step. `GH_TOKEN` is the token generated in the first step.
|
||||||
- name: Set fields
|
- name: Set fields
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: {% raw %}${{ steps.generate_token.outputs.token }}{% endraw %}
|
GH_TOKEN: {% raw %}${{ steps.generate_token.outputs.token }}{% endraw %}
|
||||||
# Sets the value of the `Status` field to `Todo`. Sets the value of the `Date posted` field.
|
# Sets the value of the `Status` field to `Todo`. Sets the value of the `Date posted` field.
|
||||||
run: |
|
run: |
|
||||||
gh api graphql -f query='
|
gh api graphql -f query='
|
||||||
@@ -223,7 +223,7 @@ jobs:
|
|||||||
# Replace `YOUR_PROJECT_NUMBER` with your project number. To find the project number, look at the project URL. For example, `https://github.com/orgs/octo-org/projects/5` has a project number of 5.
|
# Replace `YOUR_PROJECT_NUMBER` with your project number. To find the project number, look at the project URL. For example, `https://github.com/orgs/octo-org/projects/5` has a project number of 5.
|
||||||
- name: Get project data
|
- name: Get project data
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: {% raw %}${{ secrets.YOUR_TOKEN }}{% endraw %}
|
GH_TOKEN: {% raw %}${{ secrets.YOUR_TOKEN }}{% endraw %}
|
||||||
ORGANIZATION: YOUR_ORGANIZATION
|
ORGANIZATION: YOUR_ORGANIZATION
|
||||||
PROJECT_NUMBER: YOUR_PROJECT_NUMBER
|
PROJECT_NUMBER: YOUR_PROJECT_NUMBER
|
||||||
# Uses [{% data variables.product.prodname_cli %}](https://cli.github.com/manual/) to query the API for the ID of the project and return the name and ID of the first 20 fields in the project. `fields` returns a union and the query uses inline fragments (`... on`) to return information about any `ProjectV2Field` and `ProjectV2SingleSelectField` fields. The response is stored in a file called `project_data.json`.
|
# Uses [{% data variables.product.prodname_cli %}](https://cli.github.com/manual/) to query the API for the ID of the project and return the name and ID of the first 20 fields in the project. `fields` returns a union and the query uses inline fragments (`... on`) to return information about any `ProjectV2Field` and `ProjectV2SingleSelectField` fields. The response is stored in a file called `project_data.json`.
|
||||||
@@ -267,7 +267,7 @@ jobs:
|
|||||||
# Sets environment variables for this step. Replace `YOUR_TOKEN` with the name of the secret that contains your {% data variables.product.pat_generic %}.
|
# Sets environment variables for this step. Replace `YOUR_TOKEN` with the name of the secret that contains your {% data variables.product.pat_generic %}.
|
||||||
- name: Add PR to project
|
- name: Add PR to project
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: {% raw %}${{ secrets.YOUR_TOKEN }}{% endraw %}
|
GH_TOKEN: {% raw %}${{ secrets.YOUR_TOKEN }}{% endraw %}
|
||||||
PR_ID: {% raw %}${{ github.event.pull_request.node_id }}{% endraw %}
|
PR_ID: {% raw %}${{ github.event.pull_request.node_id }}{% endraw %}
|
||||||
# Uses [{% data variables.product.prodname_cli %}](https://cli.github.com/manual/) and the API to add the pull request that triggered this workflow to the project. The `jq` flag parses the response to get the ID of the created item.
|
# Uses [{% data variables.product.prodname_cli %}](https://cli.github.com/manual/) and the API to add the pull request that triggered this workflow to the project. The `jq` flag parses the response to get the ID of the created item.
|
||||||
run: |
|
run: |
|
||||||
@@ -290,7 +290,7 @@ jobs:
|
|||||||
# Sets environment variables for this step. Replace `YOUR_TOKEN` with the name of the secret that contains your {% data variables.product.pat_generic %}.
|
# Sets environment variables for this step. Replace `YOUR_TOKEN` with the name of the secret that contains your {% data variables.product.pat_generic %}.
|
||||||
- name: Set fields
|
- name: Set fields
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: {% raw %}${{ secrets.YOUR_TOKEN }}{% endraw %}
|
GH_TOKEN: {% raw %}${{ secrets.YOUR_TOKEN }}{% endraw %}
|
||||||
# Sets the value of the `Status` field to `Todo`. Sets the value of the `Date posted` field.
|
# Sets the value of the `Status` field to `Todo`. Sets the value of the `Date posted` field.
|
||||||
run: |
|
run: |
|
||||||
gh api graphql -f query='
|
gh api graphql -f query='
|
||||||
|
|||||||
Reference in New Issue
Block a user