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

Skip to content

Commit bfb7c23

Browse files
committed
Add instructions for using a separate GitHub token
1 parent c32ce14 commit bfb7c23

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,3 +350,32 @@ jobs:
350350
351351
console.log(`Hello ${FIRST_NAME} ${LAST_NAME}`)
352352
```
353+
354+
### Using a separate GitHub token
355+
356+
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).
357+
358+
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.
359+
360+
[Learn more about creating and using encrypted secrets](https://docs.github.com/actions/reference/encrypted-secrets)
361+
362+
```yaml
363+
on:
364+
issues:
365+
types: [opened]
366+
367+
jobs:
368+
apply-label:
369+
runs-on: ubuntu-latest
370+
steps:
371+
- uses: actions/github-script@v4
372+
with:
373+
github-token: ${{ secrets.MY_PAT }}
374+
script: |
375+
github.issues.addLabels({
376+
issue_number: context.issue.number,
377+
owner: context.repo.owner,
378+
repo: context.repo.repo,
379+
labels: ['Triage']
380+
})
381+
```

0 commit comments

Comments
 (0)