mirror of
https://github.com/actions/github-script.git
synced 2025-12-08 08:06:23 +00:00
Merge pull request #152 from actions/joshmgross/add-instructions-for-pat
Add instructions for using a separate GitHub token
This commit is contained in:
29
README.md
29
README.md
@@ -350,3 +350,32 @@ jobs:
|
|||||||
|
|
||||||
console.log(`Hello ${FIRST_NAME} ${LAST_NAME}`)
|
console.log(`Hello ${FIRST_NAME} ${LAST_NAME}`)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Using a separate GitHub token
|
||||||
|
|
||||||
|
The `GITHUB_TOKEN` used by default is scoped to the current repository, see [Authentication in a workflow](https://docs.github.com/actions/reference/authentication-in-a-workflow).
|
||||||
|
|
||||||
|
If you need access to a different repository or an API that the `GITHUB_TOKEN` doesn't have permissions to, you can provide your own [PAT](https://help.github.com/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line) as a secret using the `github-token` input.
|
||||||
|
|
||||||
|
[Learn more about creating and using encrypted secrets](https://docs.github.com/actions/reference/encrypted-secrets)
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
on:
|
||||||
|
issues:
|
||||||
|
types: [opened]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
apply-label:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/github-script@v4
|
||||||
|
with:
|
||||||
|
github-token: ${{ secrets.MY_PAT }}
|
||||||
|
script: |
|
||||||
|
github.issues.addLabels({
|
||||||
|
issue_number: context.issue.number,
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
labels: ['Triage']
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user