From baedf058bd7c7f703c9c03b828e174743a096d6f Mon Sep 17 00:00:00 2001 From: Andrea Brancaleoni Date: Wed, 8 May 2024 14:56:35 +0200 Subject: [PATCH] action.yml: move away from actions for addLabel --- action.yml | 16 ++++++++++------ src/steps/addLabel.js | 12 ++++++++++++ 2 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 src/steps/addLabel.js diff --git a/action.yml b/action.yml index bdac4b45..f2950528 100644 --- a/action.yml +++ b/action.yml @@ -262,16 +262,20 @@ runs: uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 with: script: return true - - uses: actions-ecosystem/action-add-labels@18f1af5e3544586314bbe15c0273249c770b2daf # v1.1.3 + - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 if: ${{ steps.unverified-commits.outputs.result == '"UNVERIFIED-CHANGED"' }} with: - github_token: ${{ inputs.github_token }} - labels: unverified-commits - - uses: actions-ecosystem/action-add-labels@18f1af5e3544586314bbe15c0273249c770b2daf # v1.1.3 + script: | + const actionPath = '${{ github.action_path }}' + const {default: addLabel} = await import(`${actionPath}/src/steps/addLabel.js`) + return await addLabel({context, github, 'unverified-commits'}) + - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 if: ${{ (steps.reviewdog-enabled-pr.outputs.result == 'true' && steps.should-trigger.outputs.result == 'true') }} with: - github_token: ${{ inputs.github_token }} - labels: needs-security-review + script: | + const actionPath = '${{ github.action_path }}' + const {default: addLabel} = await import(`${actionPath}/src/steps/addLabel.js`) + return await addLabel({context, github, 'needs-security-review'}) - uses: actions-ecosystem/action-add-assignees@a5b84af721c4a621eb9c7a4a95ec20a90d0b88e9 # v1.0.1 if: ${{ steps.reviewdog-enabled-pr.outputs.result == 'true' && steps.should-trigger.outputs.result == 'true' }} with: diff --git a/src/steps/addLabel.js b/src/steps/addLabel.js new file mode 100644 index 00000000..7521df04 --- /dev/null +++ b/src/steps/addLabel.js @@ -0,0 +1,12 @@ +export default async function addLabel ({ + github, + context, + label +}) { + return github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + labels: [label] + }) +}