From fd96f2fe1fba6f8a3af08c946f5f84afdec97643 Mon Sep 17 00:00:00 2001 From: Tomoya Kashifuku Date: Tue, 5 Mar 2024 23:44:27 +0900 Subject: [PATCH] apply this change --- .github/workflows/test-action.yml | 12 ------------ src/main.ts | 10 ++-------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/.github/workflows/test-action.yml b/.github/workflows/test-action.yml index af1848a..667fba0 100644 --- a/.github/workflows/test-action.yml +++ b/.github/workflows/test-action.yml @@ -19,21 +19,9 @@ jobs: id: checkout uses: actions/checkout@v4 - - name: Get PR_NUMBER for issue_comment triggered events - id: get-pr-number - if: github.event.issue.pull_request - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - PR_URL="${{ github.event.issue.pull_request.url }}" - PR_NUM=${PR_URL##*/} - echo "pr-number=$PR_NUM" >> "$GITHUB_OUTPUT" - - name: Test Local Action id: test-action uses: ./ - with: - pr_number: ${{ steps.get-pr-number.outputs.pr-number }} - name: Print Output id: output diff --git a/src/main.ts b/src/main.ts index b0ea662..28d0ac2 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,5 +1,6 @@ import * as core from '@actions/core' import { getOctokit, context } from '@actions/github' +import { getOption } from './option' const uniqueStringArray = (texts: string[]): string[] => { if (texts.length === 0) return [] @@ -22,15 +23,8 @@ const uniqueStringArray = (texts: string[]): string[] => { */ export async function run(): Promise { try { - const prNumber = - context.payload.pull_request?.number || - Number(core.getInput('pr_number', { required: false })) - if (isNaN(prNumber) || prNumber === 0) { - core.setFailed('pr number is not set properly') - return - } + const { token, prNumber } = getOption() - const token = core.getInput('github_token', { required: true }) const octokit = getOctokit(token) const owner = context.repo.owner const repo = context.repo.repo