Skip to content

Commit

Permalink
feat/refactor: define actions input and use kebab-case for input name
Browse files Browse the repository at this point in the history
  • Loading branch information
phwt committed Oct 7, 2024
1 parent 7c34c2c commit eb65863
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Check quality gate result from latest analysis and report result in the pull req
| disable-pr-comment | Disable commenting result on the pull request | `false` | false |
| fail-on-quality-gate-error | Set the action status to failed when quality gate status is `ERROR` | `false` | false |
| branch | Branch name to retrieve the quality gate result | `false` | |
| pullRequest | Pull request id to retrieve the quality gate result | `false` | |
| pull-request | Pull request id to retrieve the quality gate result | `false` | |

<!-- action-docs-inputs -->

Expand Down Expand Up @@ -56,7 +56,7 @@ jobs:
sonar-token: ${{ secrets.SONAR_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
branch: main # Optional input
pullRequest: 8 # Optional input
pull-request: 8 # Optional input

- name: Output result
run: |
Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:
sonar-token: ${{ secrets.SONAR_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
branch: main # Optional input
pullRequest: 8 # Optional input
pull-request: 8 # Optional input

- name: Output result
run: |
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ inputs:
branch:
description: "Branch name to retrieve the quality gate result"
required: false
pullRequest:
pull-request:
description: "Pull request id to retrieve the quality gate result"
required: false
outputs:
Expand Down
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ import { findComment } from "./modules/find-comment/main";
failOnQualityGateError:
core.getInput("fail-on-quality-gate-error") === "true",
branch: core.getInput("branch"),
pullRequest: core.getInput("pull-request"),
githubToken: core.getInput("github-token"),
};

const result = await fetchQualityGate(
inputs.hostURL,
inputs.projectKey,
inputs.token,
inputs.branch
inputs.branch,
inputs.pullRequest
);

core.setOutput("project-status", result.projectStatus.status);
Expand Down
2 changes: 1 addition & 1 deletion src/modules/__tests__/sonarqube-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe("fetchQualityGate", () => {
);
});

it("should make a GET request to the correct URL with `projectKey` and `pullRequest` parameter when `pullRequest` is defined", async () => {
it("should make a GET request to the correct URL with `projectKey` and `pullRequest` parameter when `pull-request` is defined", async () => {
(axios.get as jest.Mock).mockResolvedValue({});

await fetchQualityGate(
Expand Down
1 change: 1 addition & 0 deletions src/modules/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ export interface ActionInputs {
commentDisabled?: boolean;
failOnQualityGateError?: boolean;
branch?: string;
pullRequest?: string;
githubToken?: string;
}

0 comments on commit eb65863

Please sign in to comment.