From c555e77ad0cc0b5a8f0fe9d542d9ec9d12a33209 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 11 Mar 2024 12:07:12 +0100 Subject: [PATCH] Allow to add token from within the action.yml file. --- action.yml | 4 ++++ main.go | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index d5d383c..538d995 100644 --- a/action.yml +++ b/action.yml @@ -4,6 +4,9 @@ runs: using: 'go' main: 'main.go' inputs: + token: + description: 'Access token which allow to create pull requests' + default: ${{ github.token }} title: required: false description: The title of the pull request @@ -23,6 +26,7 @@ inputs: head: description: > The pull request head branch (the one within the new code is developed). + outputs: pull-request-number: description: 'The pull request number' diff --git a/main.go b/main.go index 99e6559..c0cc77c 100644 --- a/main.go +++ b/main.go @@ -69,9 +69,9 @@ func main() { githubactions.Fatalf("could not get context: %v", err.Error()) } - token := os.Getenv("GITHUB_TOKEN") + token := githubactions.GetInput("token") fmt.Printf("Api url is %v\n", ctx.ServerURL) - fmt.Printf("Debug: GITHUB_TOKEN begins with %v (4 first characters) and length is %d\n", token[0:4], len(token)) + fmt.Printf("Debug: token begins with %v (4 first characters) and length is %d\n", token[0:4], len(token)) config, err := ParseActionConfig(*ctx) if err != nil {