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

Remove the need to explicitly pass GITHUB_TOKEN #94

Merged
merged 1 commit into from
Mar 30, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,3 @@ jobs:
fail_on_error: true
level: warning
debug: true
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: errata-ai/vale-action@reviewdog
env:
# Required, set by GitHub actions automatically:
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
```

## Repository Structure
Expand Down Expand Up @@ -131,4 +127,13 @@ with:
vale_flags: "--glob=*.txt"
```

### `token` (default: [`secrets.GITHUB_TOKEN`](https://docs.github.com/en/actions/security-guides/automatic-token-authentication))

The GitHub token to use.

```yaml
with:
token: ${{secrets.VALE_GITHUB_TOKEN}}
```

[1]: https://help.github.com/en/github/automating-your-workflow-with-github-actions/configuring-a-workflow
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ inputs:
required: false
default: ""

token:
description: "The GitHub token to use."
required: false
default: ${{ github.token }}

runs:
using: docker
image: Dockerfile
Expand Down
6 changes: 3 additions & 3 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const input = __importStar(require("./input"));
*
* See https://bit.ly/2WlFUD7 for more information.
*/
const { GITHUB_TOKEN, GITHUB_WORKSPACE } = process.env;
const { GITHUB_WORKSPACE } = process.env;
function run(actionInput) {
return __awaiter(this, void 0, void 0, function* () {
const workdir = core.getInput('workdir') || '.';
Expand All @@ -53,7 +53,7 @@ function run(actionInput) {
const vale_code = output.exitCode;
const should_fail = core.getInput('fail_on_error');
// Pipe to reviewdog ...
process.env['REVIEWDOG_GITHUB_API_TOKEN'] = GITHUB_TOKEN;
process.env['REVIEWDOG_GITHUB_API_TOKEN'] = core.getInput('token');
return yield exec.exec('/bin/reviewdog', [
'-f=rdjsonl',
`-name=vale`,
Expand Down Expand Up @@ -85,7 +85,7 @@ exports.run = run;
function main() {
return __awaiter(this, void 0, void 0, function* () {
try {
const userToken = GITHUB_TOKEN;
const userToken = core.getInput('token');
const workspace = GITHUB_WORKSPACE;
const actionInput = yield input.get(userToken, workspace);
yield run(actionInput);
Expand Down
6 changes: 3 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as input from './input';
*
* See https://bit.ly/2WlFUD7 for more information.
*/
const {GITHUB_TOKEN, GITHUB_WORKSPACE} = process.env;
const {GITHUB_WORKSPACE} = process.env;

export async function run(actionInput: input.Input): Promise<void> {
const workdir = core.getInput('workdir') || '.';
Expand All @@ -37,7 +37,7 @@ export async function run(actionInput: input.Input): Promise<void> {
const should_fail = core.getInput('fail_on_error');

// Pipe to reviewdog ...
process.env['REVIEWDOG_GITHUB_API_TOKEN'] = GITHUB_TOKEN;
process.env['REVIEWDOG_GITHUB_API_TOKEN'] = core.getInput('token');
return await exec.exec(
'/bin/reviewdog',
[
Expand Down Expand Up @@ -71,7 +71,7 @@ export async function run(actionInput: input.Input): Promise<void> {

async function main(): Promise<void> {
try {
const userToken = GITHUB_TOKEN as string;
const userToken = core.getInput('token');
const workspace = GITHUB_WORKSPACE as string;

const actionInput = await input.get(userToken, workspace);
Expand Down