From f69fa9eedd3c62a599220f4d5745230e237904be Mon Sep 17 00:00:00 2001 From: Rabih Salamey Date: Wed, 16 Nov 2022 12:51:31 -0500 Subject: [PATCH] Utilize the auto generated github token for comments (#74) * feat: use autogenerated github token for pull_request comments * update secret token usage Co-authored-by: Gaetan BOGAERT --- README.md | 3 ++- action.yml | 4 ++++ entrypoint.sh | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f0cc4a0..1c389b1 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,8 @@ When deploying an app you may need to deploy additional services, this Github Ac | `propagate_failure` | False | `true` | Fail current job if downstream job fails. | | `trigger_workflow` | False | `true` | Trigger the specified workflow. | | `wait_workflow` | False | `true` | Wait for workflow to finish. | -| `comment_downstream_url` | False | '' | A comments API URL to comment the current downstream job URL to. Default: no comment | +| `comment_downstream_url` | False | `` | A comments API URL to comment the current downstream job URL to. Default: no comment | +| `comment_github_token` | False | `${{github.token}}` | token used for pull_request comments | ## Example diff --git a/action.yml b/action.yml index 0f7a501..f6df592 100644 --- a/action.yml +++ b/action.yml @@ -42,6 +42,10 @@ inputs: description: 'Comment API link for commenting the downstream job URL' required: false default: '' + comment_github_token: + description: "The Github access token with access to the repository for comment URL. It is recommended you put this token under secrets." + required: false + default: ${{ github.token }} outputs: workflow_id: description: The ID of the workflow that was triggered by this action diff --git a/entrypoint.sh b/entrypoint.sh index 0a5406d..58dca5f 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -155,7 +155,7 @@ trigger_workflow() { comment_downstream_link() { if response=$(curl --fail-with-body -sSL -X POST \ "${INPUT_COMMENT_DOWNSTREAM_URL}" \ - -H "Authorization: Bearer ${INPUT_GITHUB_TOKEN}" \ + -H "Authorization: Bearer ${INPUT_COMMENT_GITHUB_TOKEN}" \ -H 'Accept: application/vnd.github.v3+json' \ -d "{\"body\": \"Running downstream job at $1\"}") then