Skip to content

Commit 17454d6

Browse files
feat: support a separate token for destination (#185)
* feat: support a separate token for destination This implements the feature @sebastienrospars suggested in #174 * docs: automated doc update * feat: use dest_token
1 parent f6e0a2b commit 17454d6

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ jobs:
6161
| parameter | description | required | default |
6262
| - | - | - | - |
6363
| token | Github token | `true` | |
64+
| dest_token | Github token used for destination repo. If not set, token parameter is used | `false` | |
6465
| src_repo | Source repo to clone from | `true` | |
6566
| src_repo_github_api_url | API repo for the src_repo. Defaults to Github. Set this if using GHE | `false` | https://api.github.com |
6667
| dest_repo | Destination repo to clone to, default is this repo | `false` | |

action.yml

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ inputs:
55
token:
66
description: "Github token"
77
required: true
8+
dest_token:
9+
description: "Github token used for destination repo. If not set, token parameter is used"
10+
required: false
811
src_repo:
912
description: "Source repo to clone from"
1013
required: true

gha_clone_releases/main.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
###START_INPUT_AUTOMATION###
1313
INPUTS = {
1414
"token": {"description": "Github token", "required": True},
15+
"dest_token": {
16+
"description": "Github token used for destination repo. If not set, token parameter is used",
17+
"required": False,
18+
},
1519
"src_repo": {"description": "Source repo to clone from", "required": True},
1620
"src_repo_github_api_url": {
1721
"description": "API repo for the src_repo. Defaults to Github. Set this if using GHE",
@@ -101,6 +105,9 @@ def get_inputs() -> dict[str, Any]:
101105
parsed_inputs["dest_repo"] = (
102106
os.environ.get("GITHUB_REPOSITORY") if parsed_inputs["dest_repo"] is None else parsed_inputs["dest_repo"]
103107
)
108+
parsed_inputs["dest_token"] = (
109+
parsed_inputs["token"] if parsed_inputs["dest_token"] is None else parsed_inputs["dest_token"]
110+
)
104111
if parsed_inputs["dest_repo"] is None:
105112
actions_toolkit.set_failed("Dest repo is none, set either INPUT_DEST_REPO or GITHUB_REPOSITORY")
106113
return parsed_inputs
@@ -116,7 +123,7 @@ def main():
116123
dest_github = (
117124
src_github
118125
if inputs["dest_repo_github_api_url"] == inputs["src_repo_github_api_url"]
119-
else Github(inputs["token"], base_url=inputs["dest_repo_github_api_url"])
126+
else Github(inputs["dest_token"], base_url=inputs["dest_repo_github_api_url"])
120127
)
121128
src_releases = src_github.get_repo(inputs["src_repo"]).get_releases()
122129

0 commit comments

Comments
 (0)