Skip to content

Commit

Permalink
better syntax
Browse files Browse the repository at this point in the history
Signed-off-by: Sachin Panayil <[email protected]>
  • Loading branch information
sachin-panayil committed Dec 23, 2024
1 parent 02591aa commit 1f281c6
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ inputs:
This option will be ignored if output_type != "issue".
default: 'fbca04'
labels:
pull_request_labels:
required: false
description: >
The labels that you want to use to add to your properly.
Expand All @@ -135,7 +135,7 @@ runs:
INPUT_OUTPUT_NAME: ${{ inputs.output_name }}
INPUT_LABEL_NAME: ${{ inputs.label_name }}
INPUT_LABEL_COLOR: ${{ inputs.label_color }}
INPUT_LABELS: ${{ inputs.labels }}
INPUT_PULL_REQUEST_LABELS: ${{ inputs.pull_request_labels }}
branding:
color: green
icon: refresh-cw
9 changes: 5 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ function getInputs() {
LABEL_NAME: core.getInput("label_name" /* LABEL_NAME */, { required: true }),
LABEL_COLOR: core.getInput("label_color" /* LABEL_COLOR */, { required: true }),
BASE_BRANCH: core.getInput("base_branch" /* BASE_BRANCH */, { required: true }),
LABELS: core.getInput("labels" /* LABELS */, { required: true })
PULL_REQUEST_LABELS: core.getInput("pull_request_labels" /* PULL_REQUEST_LABELS */, { required: true })
};
}
function getRunNumber() {
Expand Down Expand Up @@ -631,7 +631,7 @@ function run(disableRetry) {
// load the configuration from file or url, depending on which one is configured
try {
// get all inputs
const { DIRECTORY, TOKEN, USERNAME, CONFIG_FILE, CONFIG_URL, REPO, OUTPUT_TYPE, OUTPUT_NAME, LABEL_NAME, LABEL_COLOR, BASE_BRANCH, LABELS } = getInputs();
const { DIRECTORY, TOKEN, USERNAME, CONFIG_FILE, CONFIG_URL, REPO, OUTPUT_TYPE, OUTPUT_NAME, LABEL_NAME, LABEL_COLOR, BASE_BRANCH, PULL_REQUEST_LABELS } = getInputs();
const RUN_NUMBER = getRunNumber();
// verify the directory exists and is a directory
try {
Expand Down Expand Up @@ -722,6 +722,7 @@ function run(disableRetry) {
core.startGroup('Sending a PR');
try {
const [owner, repo] = REPO.split('/');
const cleanedLabels = cleanLabels(PULL_REQUEST_LABELS);
const jsonOutput = repolinter_1.jsonFormatter.formatOutput(result, true);
const files = getFileChanges_1.getFileChanges(jsonOutput);
if (Object.keys(files).length !== 0) {
Expand All @@ -732,15 +733,15 @@ function run(disableRetry) {
body: getPRBody(result),
base: BASE_BRANCH,
head: `repolinter-results-#${RUN_NUMBER}`,
labels: cleanLabels(LABELS),
labels: cleanedLabels,
changes: [{
files,
commit: `changes based on repolinter output`
}]
});
if (pr) {
core.info(`Created PR: ${pr.data.html_url}`);
core.info(`Labels: ${LABELS}`);
core.info(`Created Labels for PR: ${cleanedLabels}`);
}
}
else {
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const enum ActionInputs {
LABEL_NAME = 'label_name',
LABEL_COLOR = 'label_color',
BASE_BRANCH = "base_branch",
LABELS = 'labels'
PULL_REQUEST_LABELS = 'pull_request_labels'
}

export const enum ActionOutputs {
Expand Down
11 changes: 7 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function getInputs(): {[key: string]: string} {
LABEL_NAME: core.getInput(ActionInputs.LABEL_NAME, {required: true}),
LABEL_COLOR: core.getInput(ActionInputs.LABEL_COLOR, {required: true}),
BASE_BRANCH: core.getInput(ActionInputs.BASE_BRANCH, {required: true}),
LABELS: core.getInput(ActionInputs.LABELS, {required: true})
PULL_REQUEST_LABELS: core.getInput(ActionInputs.PULL_REQUEST_LABELS, {required: true})
}
}

Expand Down Expand Up @@ -89,7 +89,7 @@ export default async function run(disableRetry?: boolean): Promise<void> {
LABEL_NAME,
LABEL_COLOR,
BASE_BRANCH,
LABELS
PULL_REQUEST_LABELS
} = getInputs()
const RUN_NUMBER = getRunNumber()
// verify the directory exists and is a directory
Expand Down Expand Up @@ -180,9 +180,12 @@ export default async function run(disableRetry?: boolean): Promise<void> {

try {
const [owner, repo] = REPO.split('/')
const cleanedLabels = cleanLabels(PULL_REQUEST_LABELS)

const jsonOutput = jsonFormatter.formatOutput(result, true)
const files = getFileChanges(jsonOutput)


if (Object.keys(files).length !== 0) {
const pr = await octokit.createPullRequest({
owner,
Expand All @@ -191,7 +194,7 @@ export default async function run(disableRetry?: boolean): Promise<void> {
body: getPRBody(result),
base: BASE_BRANCH,
head: `repolinter-results-#${RUN_NUMBER}`,
labels: cleanLabels(LABELS),
labels: cleanedLabels,
changes: [{
files,
commit: `changes based on repolinter output`
Expand All @@ -200,7 +203,7 @@ export default async function run(disableRetry?: boolean): Promise<void> {

if (pr) {
core.info(`Created PR: ${pr.data.html_url}`)
core.info(`Labels: ${LABELS}`)
core.info(`Created Labels for PR: ${cleanedLabels}`)
}

} else {
Expand Down

0 comments on commit 1f281c6

Please sign in to comment.