From ae76476e8f64a7c00cd41e496ba71d5ef42dfe06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Rospars?= Date: Thu, 25 Jan 2024 13:09:22 +0100 Subject: [PATCH] feat: Add possibility to dissociate token for source and destination repository --- README.md | 1 + action.yml | 3 +++ gha_clone_releases/main.py | 11 +++++++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7c35217..dd38a46 100644 --- a/README.md +++ b/README.md @@ -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` | | diff --git a/action.yml b/action.yml index 0aafbd3..011cbcf 100644 --- a/action.yml +++ b/action.yml @@ -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 diff --git a/gha_clone_releases/main.py b/gha_clone_releases/main.py index 1444ec4..05bd865 100644 --- a/gha_clone_releases/main.py +++ b/gha_clone_releases/main.py @@ -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", @@ -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() @@ -184,4 +191,4 @@ def main(): if __name__ == "__main__": - main() + main() \ No newline at end of file