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: Add possibility to dissociate token for source and destination repository #174

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ jobs:
| parameter | description | required | default |
| - | - | - | - |
| token | Github token | `true` | |
| dest_token | Github token used for destination repo. If not set, `token` parameter is used. | `false` | |
| src_repo | Source repo to clone from | `true` | |
| src_repo_github_api_url | API repo for the src_repo. Defaults to Github. Set this if using GHE | `false` | https://api.github.com |
| dest_repo | Destination repo to clone to, default is this repo | `false` | |
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ inputs:
token:
description: "Github token"
required: true
dest_token:
description: "Github token used for destination repo. If not set, token parameter is used"
required: false
src_repo:
description: "Source repo to clone from"
required: true
Expand Down
11 changes: 9 additions & 2 deletions gha_clone_releases/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
###START_INPUT_AUTOMATION###
INPUTS = {
"token": {"description": "Github token", "required": True},
"dest_token": {
"description": "Github token used for destination repo. If not set, token parameter is used",
"required": False
},
"src_repo": {"description": "Source repo to clone from", "required": True},
"src_repo_github_api_url": {
"description": "API repo for the src_repo. Defaults to Github. Set this if using GHE",
Expand Down Expand Up @@ -116,7 +120,10 @@ def main():
dest_github = (
src_github
if inputs["dest_repo_github_api_url"] == inputs["src_repo_github_api_url"]
else Github(inputs["token"], base_url=inputs["dest_repo_github_api_url"])
else Github(
inputs["dest_token"] if "dest_token" in inputs else inputs["token"],
base_url=inputs["dest_repo_github_api_url"]
)
)
src_releases = src_github.get_repo(inputs["src_repo"]).get_releases()

Expand Down Expand Up @@ -184,4 +191,4 @@ def main():


if __name__ == "__main__":
main()
main()
Loading