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

Set default token for simpler setup #83

Merged
merged 3 commits into from Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 6 additions & 14 deletions README.md
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -163,8 +155,7 @@ jobs:
with:
body_path: ${{ github.workflow }}-CHANGELOG.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: my_gh_org/my_gh_repo
GITHUB_REPOSITORY: my_gh_org/my_gh_repo
```

### 💅 Customizing
Expand All @@ -183,6 +174,7 @@ The following are optional as `step.with` keys
| `name` | String | Name of the release. defaults to tag name |
| `tag_name` | String | Name of a tag. defaults to `github.ref` |
| `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.

Expand All @@ -198,11 +190,11 @@ The following outputs can be accessed via `${{ steps.<step-id>.outputs }}` from

#### 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` |
| `GITHUB_REPOSITORY` | Name of a target repository in `<owner>/<repo>` format. defaults to the current repository|


Expand Down
4 changes: 4 additions & 0 deletions action.yml
Expand Up @@ -30,6 +30,10 @@ inputs:
repository:
description: 'Repository to make releases against, in <owner>/<repo> 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:
Expand Down
3 changes: 2 additions & 1 deletion src/util.ts
@@ -1,3 +1,4 @@
import { getInput } from "@actions/core";
import * as glob from "glob";
import { lstatSync, readFileSync } from "fs";

Expand Down Expand Up @@ -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,
Expand Down