Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: optional token in checkout and in comment-pr #298

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions actions/checkout/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ permissions:
#
# Default: false
lfs: ""

# Description: Token to use for checking out the repository instead of the default GITHUB_TOKEN.
# If specified and not empty, persist-credentials in checkout will be false.
#
token: ""
```

<!-- end usage -->
Expand All @@ -57,6 +62,7 @@ permissions:
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------- | ------------ |
| <code>fetch-depth</code> | Number of commits to fetch. 0 indicates all history for all branches and tags. See [https://github.com/actions/checkout#usage](https://github.com/actions/checkout#usage) | <code>1</code> | **false** |
| <code>lfs</code> | Whether to download Git-LFS files. See [https://github.com/actions/checkout#usage](https://github.com/actions/checkout#usage) | | **false** |
| <code>token</code> | Token to use for checking out the repository instead of the default GITHUB_TOKEN. If specified and not empty, persist-credentials in checkout will be false. | | **false** |

<!-- end inputs -->
<!-- start outputs -->
Expand Down
9 changes: 9 additions & 0 deletions actions/checkout/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ inputs:
lfs:
description: "Whether to download Git-LFS files. See [https://github.com/actions/checkout#usage](https://github.com/actions/checkout#usage)"
default: false
token:
description: |
Token to use for checking out the repository instead of the default GITHUB_TOKEN.
If specified and not empty, persist-credentials in checkout will be false.
required: false

runs:
using: "composite"
Expand All @@ -22,9 +27,13 @@ runs:
ref: refs/pull/${{ github.event.issue.number }}/head
fetch-depth: ${{ inputs.fetch-depth }}
lfs: ${{ inputs.lfs }}
token: ${{ inputs.token || github.token }}
persist-credentials: ${{ inputs.token == '' }}

- uses: actions/checkout@v4
if: github.event_name != 'issue_comment'
with:
fetch-depth: ${{ inputs.fetch-depth }}
lfs: ${{ inputs.lfs }}
token: ${{ inputs.token || github.token }}
persist-credentials: ${{ inputs.token == '' }}
12 changes: 11 additions & 1 deletion actions/create-or-update-comment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ permissions:
# [https://github.com/peter-evans/create-or-update-comment](https://github.com/peter-evans/create-or-update-comment)
#
reactions: ""

# Description: The comment author. Default is github-actions[bot].
#
comment-author: ""

# Description: Optional token to interact with GitHub API.
# If not defined or empty, the action will use the GITHUB_TOKEN provided by GitHub.
#
token: ""
```

<!-- end usage -->
Expand All @@ -59,7 +68,8 @@ permissions:
| <code>title</code> | The comment title. Must be static and unique, will be used to retrieve the comment if exists already. | | **true** |
| <code>body</code> | The comment body. See [https://github.com/peter-evans/create-or-update-comment](https://github.com/peter-evans/create-or-update-comment) | | **false** |
| <code>reactions</code> | A comma separated list of reactions to add to the comment. See [https://github.com/peter-evans/create-or-update-comment](https://github.com/peter-evans/create-or-update-comment) | | **false** |

| <code>comment-author</code> | The comment author. Default is github-actions[bot]. | github-actions[bot] | **false** |
| <code>token</code> | Optional token to interact with GitHub API. If not defined or empty, the action will use the GITHUB_TOKEN provided by GitHub. | | **false** |
<!-- end inputs -->
<!-- start outputs -->
<!-- end outputs -->
Expand Down
14 changes: 13 additions & 1 deletion actions/create-or-update-comment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ inputs:
reactions:
description: "A comma separated list of reactions to add to the comment. See [https://github.com/peter-evans/create-or-update-comment](https://github.com/peter-evans/create-or-update-comment)"
required: false
comment-author:
description: "The comment author. Default is github-actions[bot]."
required: false
default: "github-actions[bot]"
token:
description: |
Optional token to interact with GitHub API.
If not defined or empty, the action will use the GITHUB_TOKEN provided by GitHub.
required: false

runs:
using: "composite"
Expand All @@ -36,8 +45,10 @@ runs:
id: find-comment
with:
issue-number: ${{ steps.get-issue-number.outputs.issue-number }}
comment-author: github-actions[bot]
comment-author: ${{ inputs.comment-author }}
body-includes: ${{ inputs.title }}
token: ${{ inputs.token || github.token }}


- uses: peter-evans/create-or-update-comment@v4
with:
Expand All @@ -49,3 +60,4 @@ runs:

${{ inputs.body }}
reactions: ${{ inputs.reactions }}
token: ${{ inputs.token || github.token }}