From d5e4f508ae901004f0f2810c8b9fca8e94e38b5c Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 16 Mar 2021 07:50:02 +0300 Subject: [PATCH 1/2] Accept PAT as input and default to typically usable value --- action.yml | 4 ++++ src/util.ts | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index ab29e8a05..74a5d9448 100644 --- a/action.yml +++ b/action.yml @@ -30,6 +30,10 @@ inputs: repository: description: 'Repository to make releases against, in / format' required: false + token: + description: 'Authorized secret GitHub Personal Access Token. Defaults to github.token' + required: false + default: ${{ github.token }} env: 'GITHUB_TOKEN': 'As provided by Github Actions' outputs: diff --git a/src/util.ts b/src/util.ts index 6c1dce971..35e0d8010 100644 --- a/src/util.ts +++ b/src/util.ts @@ -1,3 +1,4 @@ +import { getInput } from "@actions/core"; import * as glob from "glob"; import { lstatSync, readFileSync } from "fs"; @@ -40,7 +41,7 @@ export const parseInputFiles = (files: string): string[] => { export const parseConfig = (env: Env): Config => { return { - github_token: env.GITHUB_TOKEN || "", + github_token: getInput("token") || env.GITHUB_TOKEN || "", github_ref: env.GITHUB_REF || "", github_repository: env.INPUT_REPOSITORY || env.GITHUB_REPOSITORY || "", input_name: env.INPUT_NAME, From 7e3b173db6e55f66d7022cff275809ede832011b Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 16 Mar 2021 07:50:23 +0300 Subject: [PATCH 2/2] Document use of token input parameter and deprecate env var --- README.md | 47 +++++++++++++++++++---------------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index fc1698a99..a2430a0ff 100644 --- a/README.md +++ b/README.md @@ -47,8 +47,6 @@ jobs: - name: Release uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ``` You can also use push config tag filter @@ -69,8 +67,6 @@ jobs: uses: actions/checkout@v2 - name: Release uses: softprops/action-gh-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ``` ### ⬆️ Uploading release assets @@ -104,8 +100,6 @@ jobs: if: startsWith(github.ref, 'refs/tags/') with: files: Release.txt - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ``` Below is an example of uploading more than one asset with a GitHub release @@ -132,8 +126,6 @@ jobs: files: | Release.txt LICENSE - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ``` > **⚠️ Note:** Notice the `|` in the yaml syntax above ☝️. That let's you effectively declare a multi-line yaml string. You can learn more about multi-line yaml syntax [here](https://yaml-multiline.info) @@ -162,8 +154,6 @@ jobs: if: startsWith(github.ref, 'refs/tags/') with: body_path: ${{ github.workflow }}-CHANGELOG.txt - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ``` ### 💅 Customizing @@ -172,17 +162,18 @@ jobs: The following are optional as `step.with` keys -| Name | Type | Description | -|---------------------------|---------|-----------------------------------------------------------------------| -| `body` | String | Text communicating notable changes in this release | -| `body_path` | String | Path to load text communicating notable changes in this release | -| `draft` | Boolean | Indicator of whether or not this release is a draft | -| `prerelease` | Boolean | Indicator of whether or not is a prerelease | -| `files` | String | Newline-delimited globs of paths to assets to upload for release | -| `name` | String | Name of the release. defaults to tag name | -| `tag_name` | String | Name of a tag. defaults to `github.ref` | -| `repository` | String | Name of a target repository in `/` format. defaults to the current repository -| `fail_on_unmatched_files` | Boolean | Indicator of whether to fail if any of the `files` globs match nothing| +| Name | Type | Description | +|---------------------------|---------|---------------------------------------------------------------------------------------------| +| `body` | String | Text communicating notable changes in this release | +| `body_path` | String | Path to load text communicating notable changes in this release | +| `draft` | Boolean | Indicator of whether or not this release is a draft | +| `prerelease` | Boolean | Indicator of whether or not is a prerelease | +| `files` | String | Newline-delimited globs of paths to assets to upload for release | +| `name` | String | Name of the release. defaults to tag name | +| `tag_name` | String | Name of a tag. defaults to `github.ref` | +| `repository` | String | Name of a target repository in `/` format. Defaults to the current repository. | +| `fail_on_unmatched_files` | Boolean | Indicator of whether to fail if any of the `files` globs match nothing | +| `token` | String | Secret GitHub Personal Access Token. Defaults to `${{ github.token }}` | 💡When providing a `body` and `body_path` at the same time, `body_path` will be attempted first, then falling back on `body` if the path can not be read from. @@ -190,18 +181,18 @@ The following are optional as `step.with` keys The following outputs can be accessed via `${{ steps..outputs }}` from this action -| Name | Type | Description | -|-------------|---------|-----------------------------------------------------------------| -| `url` | String | Github.com URL for the release | +| Name | Type | Description | +|-------------|---------|--------------------------------| +| `url` | String | Github.com URL for the release | #### environment variables -The following are *required* as `step.env` keys +The following `step.env` keys are allowed as a fallback but deprecated in favor of using inputs. -| Name | Description | -|----------------|--------------------------------------| -| `GITHUB_TOKEN` | GITHUB_TOKEN as provided by `secrets`| +| Name | Description | +|----------------|---------------------------------------| +| `GITHUB_TOKEN` | GITHUB_TOKEN as provided by `secrets` | > **⚠️ Note:** This action was previously implemented as a Docker container, limiting its use to GitHub Actions Linux virtual environments only. With recent releases, we now support cross platform usage. You'll need to remove the `docker://` prefix in these versions