1
0
mirror of synced 2025-12-19 18:10:59 -05:00

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:
Mark Maxwell
2024-01-02 02:38:41 -06:00
committed by GitHub
parent a5bde76a8a
commit bb17f61c51
10 changed files with 26 additions and 26 deletions

View File

@@ -46,14 +46,14 @@ In the tutorial, you will first make a workflow file that uses the {% data varia
steps:
- run: gh issue edit "$NUMBER" --add-label "$LABELS"
env:
GITHUB_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
GH_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
GH_REPO: {% raw %}${{ github.repository }}{% endraw %}
NUMBER: {% raw %}${{ github.event.issue.number }}{% endraw %}
LABELS: triage
```
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)."
1. {% data reusables.actions.commit-workflow %}

View File

@@ -45,7 +45,7 @@ In the tutorial, you will first make a workflow file that uses the `gh issue com
- name: Add comment
run: gh issue comment "$NUMBER" --body "$BODY"
env:
GITHUB_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
GH_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
GH_REPO: {% raw %}${{ github.repository }}{% endraw %}
NUMBER: {% raw %}${{ github.event.issue.number }}{% endraw %}
BODY: >

View File

@@ -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"
fi
env:
GITHUB_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
GH_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
GH_REPO: {% raw %}${{ github.repository }}{% endraw %}
TITLE: Team sync
ASSIGNEES: monalisa,doctocat,hubot

View File

@@ -53,13 +53,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- env:
GITHUB_TOKEN: {% raw %}${{ secrets.MY_TOKEN }}{% endraw %}
GH_TOKEN: {% raw %}${{ secrets.MY_TOKEN }}{% endraw %}
ISSUE_URL: {% raw %}${{ github.event.issue.html_url }}{% endraw %}
run: |
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
on:
@@ -72,7 +72,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- env:
GITHUB_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
GH_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
ISSUE_URL: {% raw %}${{ github.event.issue.html_url }}{% endraw %}
run: |
gh issue edit $ISSUE_URL --add-label "triage"
@@ -172,7 +172,7 @@ jobs:
steps:
- name: "Comment about changes we can't accept"
env:
GITHUB_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
GH_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
PR: {% raw %}${{ github.event.pull_request.html_url }}{% endraw %}
run: |
gh pr edit $PR --add-label 'invalid'

View File

@@ -19,7 +19,7 @@ type: how_to
{% 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.
@@ -35,7 +35,7 @@ jobs:
steps:
- run: gh issue comment $ISSUE --body "Thank you for opening this issue!"
env:
GITHUB_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
GH_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
ISSUE: {% raw %}${{ github.event.issue.html_url }}{% endraw %}
```
@@ -64,11 +64,11 @@ jobs:
echo 'NUM_OPEN_ISSUES='$numOpenIssues >> $GITHUB_ENV
env:
GITHUB_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
GH_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
OWNER: {% raw %}${{ github.repository_owner }}{% endraw %}
REPO: {% raw %}${{ github.event.repository.name }}{% endraw %}
- run: |
gh issue create --title "Issue report" --body "$NUM_OPEN_ISSUES issues remaining" --repo $GITHUB_REPOSITORY
env:
GITHUB_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
GH_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
```

View File

@@ -56,7 +56,7 @@ jobs:
- name: Use the token
env:
GITHUB_TOKEN: {% raw %}${{ steps.generate_token.outputs.token }}{% endraw %}
GH_TOKEN: {% raw %}${{ steps.generate_token.outputs.token }}{% endraw %}
run: |
gh api octocat
```

View File

@@ -222,7 +222,7 @@ jobs:
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
```
{% endraw %}
@@ -266,7 +266,7 @@ jobs:
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
```
{% endraw %}

View File

@@ -87,7 +87,7 @@ jobs:
steps:
- run: gh pr comment $PR_URL --body "Welcome to the repository!"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_URL: ${{ github.event.pull_request.html_url }}
```
@@ -117,6 +117,6 @@ jobs:
steps:
- run: gh pr comment $PR_URL --body "Welcome to the repository!"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_URL: ${{ github.event.pull_request.html_url }}
```

View File

@@ -133,7 +133,7 @@ Code annotations only work in articles with the `layout: inline` frontmatter pro
steps:
- run: gh pr comment $PR_URL --body "Welcome to the repository!"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_URL: ${{ github.event.pull_request.html_url }}
```

View File

@@ -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.
- name: Get project data
env:
GITHUB_TOKEN: {% raw %}${{ steps.generate_token.outputs.token }}{% endraw %}
GH_TOKEN: {% raw %}${{ steps.generate_token.outputs.token }}{% endraw %}
ORGANIZATION: YOUR_ORGANIZATION
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`.
@@ -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 '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
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 %}
# 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: |
@@ -155,10 +155,10 @@ jobs:
- name: Get date
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
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.
run: |
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.
- name: Get project data
env:
GITHUB_TOKEN: {% raw %}${{ secrets.YOUR_TOKEN }}{% endraw %}
GH_TOKEN: {% raw %}${{ secrets.YOUR_TOKEN }}{% endraw %}
ORGANIZATION: YOUR_ORGANIZATION
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`.
@@ -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 %}.
- name: Add PR to project
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 %}
# 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: |
@@ -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 %}.
- name: Set fields
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.
run: |
gh api graphql -f query='