diff --git a/.github/workflows/build-assets.yml b/.github/workflows/build-assets.yml index d80d8bf661a8b3..916137d0dad97d 100644 --- a/.github/workflows/build-assets.yml +++ b/.github/workflows/build-assets.yml @@ -1,18 +1,25 @@ -name: build assets +name: Build assets on: push: branches: - master paths: - - 'lib/**' - - 'scripts/workflow/*.js' + - 'assets/radar-rules.js' + - 'lib/**/maintainer.js' + - 'lib/**/radar-rules.js' + - 'lib/**/radar.js' + +permissions: + contents: read jobs: build: runs-on: ubuntu-latest name: Build assets timeout-minutes: 5 + permissions: + contents: write steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/comment-on-issue.yml b/.github/workflows/comment-on-issue.yml index 61b518ba884bf2..258d4b6d381abf 100644 --- a/.github/workflows/comment-on-issue.yml +++ b/.github/workflows/comment-on-issue.yml @@ -9,6 +9,7 @@ jobs: name: Call maintainers runs-on: ubuntu-latest timeout-minutes: 5 + if: github.event.sender.login != 'issuehunt-oss[bot]' steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v2 diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml index 8e25b730e701c3..9f81179510d635 100644 --- a/.github/workflows/docker-release.yml +++ b/.github/workflows/docker-release.yml @@ -1,4 +1,4 @@ -name: '[docker] CI for releases' +name: 'Docker Release' on: push: @@ -13,7 +13,7 @@ on: - '!lib/v2/test/**' - '!test/**' - 'Dockerfile' - workflow_dispatch: ~ + workflow_dispatch: {} jobs: check-env: diff --git a/.github/workflows/pr-deploy-route-test.yml b/.github/workflows/docker-test-cont.yml similarity index 95% rename from .github/workflows/pr-deploy-route-test.yml rename to .github/workflows/docker-test-cont.yml index 900bb493206c48..86a9deae423a4d 100644 --- a/.github/workflows/pr-deploy-route-test.yml +++ b/.github/workflows/docker-test-cont.yml @@ -1,4 +1,5 @@ name: PR - route test + on: workflow_run: workflows: [ PR - Docker build test ] # open, reopen, synchronized, edited included @@ -32,7 +33,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Fetch affected routes - id: fetchRoute + id: fetch-route uses: actions/github-script@v6 env: PULL_REQUEST: ${{ steps.pr-data.outputs.data }} @@ -87,17 +88,17 @@ jobs: uses: actions/github-script@v6 env: TEST_BASEURL: http://localhost:1200 - TEST_ROUTES: ${{ steps.fetchRoute.outputs.result }} + TEST_ROUTES: ${{ steps.fetch-route.outputs.result }} PULL_REQUEST: ${{ steps.pr-data.outputs.data }} with: - github-token: ${{secrets.GITHUB_TOKEN}} + github-token: ${{ secrets.GITHUB_TOKEN }} script: | const PR = JSON.parse(process.env.PULL_REQUEST) const link = process.env.TEST_BASEURL const routes = JSON.parse(process.env.TEST_ROUTES) const number = PR.number core.info(`${link}, ${routes}, ${number}`) - const got = require("got"); + const got = require("got") const script = require(`${process.env.GITHUB_WORKSPACE}/scripts/workflow/test-route/test.js`) return script({ github, context, core, got }, link, routes, number) diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml index 7571ecb60f6007..7e183d3d609618 100644 --- a/.github/workflows/docker-test.yml +++ b/.github/workflows/docker-test.yml @@ -1,5 +1,3 @@ -# name: '[docker] CI for build tests' -# https://github.community/t/215358 name: PR - Docker build test on: diff --git a/.github/workflows/docs-search-index.yml b/.github/workflows/docs-search-index.yml index 2cca71ac98c38f..70516e0d87282c 100644 --- a/.github/workflows/docs-search-index.yml +++ b/.github/workflows/docs-search-index.yml @@ -8,17 +8,19 @@ on: - '.github/workflows/docs-search-index.yml' - 'scripts/docs-scraper/docs.rsshub.app.json' - 'website/**' - workflow_dispatch: ~ + workflow_dispatch: {} schedule: - cron: '44 1 * * 1' +permissions: + contents: read + concurrency: group: docs-search-index jobs: scrape-docs: runs-on: ubuntu-latest - timeout-minutes: 15 steps: - name: Checkout uses: actions/checkout@v4 @@ -28,6 +30,7 @@ jobs: run: sleep 2m if: github.event_name == 'push' - name: Run docs-scraper + timeout-minutes: 15 env: HOST_URL: ${{ secrets.MEILISEARCH_HOST_URL }} API_KEY: ${{ secrets.MEILISEARCH_API_KEY }} diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index e82387e8486fb9..40a6147e9a058a 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -1,4 +1,4 @@ -name: format +name: Format on: push: diff --git a/.github/workflows/issue-command.yml b/.github/workflows/issue-command.yml index 4e0493bbf56eab..460cc9f291cc59 100644 --- a/.github/workflows/issue-command.yml +++ b/.github/workflows/issue-command.yml @@ -13,6 +13,9 @@ jobs: if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/rebase') && github.event.comment.author_association == 'COLLABORATOR' runs-on: ubuntu-latest timeout-minutes: 5 + permissions: + contents: write + pull-requests: write steps: - name: Checkout the latest code uses: actions/checkout@v4 @@ -32,7 +35,7 @@ jobs: contents: read issues: write steps: - - uses: bdougie/take-action@v1.6 + - uses: bdougie/take-action@v1.6.1 with: token: ${{ secrets.GITHUB_TOKEN }} trigger: '/wip' @@ -64,7 +67,7 @@ jobs: run: pnpm i && pnpm rb - name: Fetch affected routes - id: fetchRoute + id: fetch-route uses: actions/github-script@v6 env: EVENT: ${{ toJson(github.event) }} @@ -91,7 +94,7 @@ jobs: uses: actions/github-script@v6 env: TEST_BASEURL: http://localhost:1200 - TEST_ROUTES: ${{ steps.fetchRoute.outputs.result }} + TEST_ROUTES: ${{ steps.fetch-route.outputs.result }} EVENT: ${{ toJson(github.event) }} with: script: | diff --git a/.github/workflows/pr-lint.yml b/.github/workflows/lint.yml similarity index 60% rename from .github/workflows/pr-lint.yml rename to .github/workflows/lint.yml index 3a1a784a5900f0..e7c388fcb0f1ff 100644 --- a/.github/workflows/pr-lint.yml +++ b/.github/workflows/lint.yml @@ -1,26 +1,35 @@ name: Linter -on: [push, pull_request, pull_request_target] +# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request +# pull_request includes [opened, reopened, synchronize] events by default +# 'edited' is required for title-lint +on: + push: {} + pull_request: + types: [opened, reopened, synchronize, edited] + pull_request_target: + types: [opened, reopened, synchronize, edited] jobs: - eslint: - name: ESLint - if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' }} - runs-on: ubuntu-latest - timeout-minutes: 5 - steps: - - uses: actions/checkout@v4 - - uses: pnpm/action-setup@v2 - with: - version: 8 - - uses: actions/setup-node@v3 - with: - node-version: lts/* - cache: 'pnpm' - - run: pnpm i - - name: Lint - run: pnpm run lint + # eslint: + # name: ESLint + # if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' }} + # runs-on: ubuntu-latest + # timeout-minutes: 5 + # steps: + # - uses: actions/checkout@v4 + # - uses: pnpm/action-setup@v2 + # with: + # version: 8 + # - uses: actions/setup-node@v3 + # with: + # node-version: lts/* + # cache: 'pnpm' + # - run: pnpm i + # - name: Lint + # run: pnpm run lint +# https://github.com/actions/starter-workflows/blob/main/code-scanning/eslint.yml eslint-warning: name: Lint if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' }} @@ -50,11 +59,14 @@ jobs: sarif_file: eslint-results.sarif wait-for-processing: true - titleLint: +# https://github.com/amannn/action-semantic-pull-request + title-lint: if: ${{ github.event_name == 'pull_request_target' && github.repository == 'DIYgod/RSSHub' }} name: Validate PR title runs-on: ubuntu-latest timeout-minutes: 5 + permissions: + pull-requests: read steps: - uses: amannn/action-semantic-pull-request@v5 env: @@ -75,21 +87,3 @@ jobs: - uses: actions/labeler@v4 with: repo-token: ${{ secrets.GITHUB_TOKEN }} - - chatgpt-review: - name: ChatGPT PR reviewer - if: ${{ github.event_name == 'pull_request_target' && false }} - permissions: - contents: read - pull-requests: write - runs-on: ubuntu-latest - timeout-minutes: 5 - steps: - - uses: fluxninja/openai-pr-reviewer@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - with: - openai_base_url: ${{ secrets.OPENAI_API_ENDPOINT }} - openai_model_temperature: '1.0' - disable_release_notes: true diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 03e77142c59db5..55459076965843 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -1,4 +1,4 @@ -name: publish +name: npm Publish on: push: diff --git a/.github/workflows/semgrep.yml b/.github/workflows/semgrep.yml index d67cc7ddccd77a..4a4f76766450f0 100644 --- a/.github/workflows/semgrep.yml +++ b/.github/workflows/semgrep.yml @@ -1,26 +1,49 @@ +name: Semgrep + +# https://semgrep.dev/docs/semgrep-ci/sample-ci-configs/#sample-github-actions-configuration-file on: pull_request_target: branches: - - master - paths: - - .github/workflows/semgrep.yml + - master push: branches: - - master - paths: - - .github/workflows/semgrep.yml + - master schedule: - # random HH:MM to avoid a load spike on GitHub Actions at 00:00 - - cron: 21 20 * * * -name: Semgrep + # random HH:MM to avoid a load spike on GitHub Actions at 00:00 + - cron: 21 20 * * * + +permissions: + contents: read + jobs: semgrep: name: Scan runs-on: ubuntu-latest - env: - SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }} container: image: returntocorp/semgrep + if: (github.actor != 'dependabot[bot]') + steps: + - uses: actions/checkout@v4 + - run: semgrep ci + env: + SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }} + + semgrep-github: + name: Scan + runs-on: ubuntu-latest + container: + image: returntocorp/semgrep + if: (github.actor != 'dependabot[bot]') + permissions: + contents: read + security-events: write steps: - - uses: actions/checkout@v4 - - run: semgrep ci + - uses: actions/checkout@v4 + - run: semgrep ci --sarif --output=semgrep.sarif + env: + SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }} + - name: Upload SARIF file for GitHub Advanced Security Dashboard + uses: github/codeql-action/upload-sarif@v2 + with: + sarif_file: semgrep.sarif + if: always() diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 90701a832db464..82dc39015eb86f 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -1,4 +1,5 @@ name: 'Close stale issues and PRs' + on: schedule: - cron: '31 23 * * *' @@ -21,3 +22,6 @@ jobs: This PR is stale because it has been opened for more than 3 weeks with no activity. Comment or this will be closed in 7 days. close-issue-message: 'This issue was closed because it has been stalled for 7 days with no activity.' close-pr-message: 'This PR was closed because it has been stalled for 7 days with no activity.' + exempt-issue-labels: 'dependencies,wait for upstream' + exempt-pr-labels: 'dependencies,wait for upstream' + any-of-labels: 'more data required' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 63356b25073d1a..0c67a309a7c84f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: test +name: Test on: push: @@ -13,7 +13,7 @@ on: - 'package.json' - 'pnpm-lock.yaml' - '.github/workflows/test.yml' - pull_request: ~ + pull_request: {} permissions: contents: read diff --git a/.github/workflows/yarn-lock-changes.yml b/.github/workflows/yarn-lock-changes.yml deleted file mode 100644 index 00b14898fe60af..00000000000000 --- a/.github/workflows/yarn-lock-changes.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Yarn Lock Changes -on: - pull_request: - paths: - - '.github/workflows/yarn-lock-changes.yml' - - 'yarn.lock' - - 'docs/yarn.lock' - -jobs: - yarn_lock_changes: - runs-on: ubuntu-latest - timeout-minutes: 5 - # Permission overwrite is required for Dependabot PRs, see https://github.com/marketplace/actions/yarn-lock-changes#-common-issues. - permissions: - pull-requests: write - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Yarn Lock Changes - uses: Simek/yarn-lock-changes@v0.11.2 - with: - token: ${{ secrets.GITHUB_TOKEN }} diff --git a/lib/maintainer.js b/lib/maintainer.js index 9efb9f448b62d8..41592e812cf394 100644 --- a/lib/maintainer.js +++ b/lib/maintainer.js @@ -37,7 +37,7 @@ for (const dir in maintainerPath) { } for (const key in routes) { - maintainers['/' + dir + key] = routes[key]; + maintainers['/' + dir + (key.endsWith('/') ? key.substring(0, key.length - 1) : key)] = routes[key]; } } @@ -49,4 +49,9 @@ router.stack.forEach((e) => { } }); -module.exports = maintainers; +module.exports = Object.keys(maintainers) + .sort() + .reduce((obj, path) => { + obj[path] = maintainers[path]; + return obj; + }, {}); diff --git a/lib/v2/bytes/maintainer.js b/lib/v2/bytes/maintainer.js index e9948c57ffa2bc..5e6a04e747cde4 100644 --- a/lib/v2/bytes/maintainer.js +++ b/lib/v2/bytes/maintainer.js @@ -1,4 +1,3 @@ module.exports = { - '': ['meixger'], '/': ['meixger'], }; diff --git a/lib/v2/chinafactcheck/maintainer.js b/lib/v2/chinafactcheck/maintainer.js index aefc7919a97731..414dc193983552 100644 --- a/lib/v2/chinafactcheck/maintainer.js +++ b/lib/v2/chinafactcheck/maintainer.js @@ -1,4 +1,3 @@ module.exports = { - '': ['kdanfly'], '/': ['kdanfly'], }; diff --git a/lib/v2/cyzone/maintainer.js b/lib/v2/cyzone/maintainer.js index 9d37fd346fb8f2..a008ce5878690f 100644 --- a/lib/v2/cyzone/maintainer.js +++ b/lib/v2/cyzone/maintainer.js @@ -1,5 +1,5 @@ module.exports = { - '': ['nczitzk'], + '/': ['nczitzk'], '/:id?': ['nczitzk'], '/author/:id': ['nczitzk'], '/channel/:id?': ['nczitzk'], diff --git a/lib/v2/deadline/maintainer.js b/lib/v2/deadline/maintainer.js index 13972819d7b162..83fc5ed48db85a 100644 --- a/lib/v2/deadline/maintainer.js +++ b/lib/v2/deadline/maintainer.js @@ -1,4 +1,3 @@ module.exports = { - '': ['TonyRL'], '/': ['TonyRL'], }; diff --git a/lib/v2/foresightnews/maintainer.js b/lib/v2/foresightnews/maintainer.js index 035f909ae0402b..41ccd63927bffe 100644 --- a/lib/v2/foresightnews/maintainer.js +++ b/lib/v2/foresightnews/maintainer.js @@ -1,5 +1,4 @@ module.exports = { - '': ['nczitzk'], '/': ['nczitzk'], '/article': ['nczitzk'], '/column/:id': ['nczitzk'], diff --git a/lib/v2/grubstreet/maintainer.js b/lib/v2/grubstreet/maintainer.js index c3c2c3b89f6c04..b478124828653f 100644 --- a/lib/v2/grubstreet/maintainer.js +++ b/lib/v2/grubstreet/maintainer.js @@ -1,4 +1,3 @@ module.exports = { - '': ['loganrockmore'], '/': ['loganrockmore'], }; diff --git a/lib/v2/guanhai/maintainer.js b/lib/v2/guanhai/maintainer.js index 13972819d7b162..83fc5ed48db85a 100644 --- a/lib/v2/guanhai/maintainer.js +++ b/lib/v2/guanhai/maintainer.js @@ -1,4 +1,3 @@ module.exports = { - '': ['TonyRL'], '/': ['TonyRL'], }; diff --git a/lib/v2/netflav/maintainer.js b/lib/v2/netflav/maintainer.js index 13972819d7b162..83fc5ed48db85a 100644 --- a/lib/v2/netflav/maintainer.js +++ b/lib/v2/netflav/maintainer.js @@ -1,4 +1,3 @@ module.exports = { - '': ['TonyRL'], '/': ['TonyRL'], }; diff --git a/lib/v2/niaogebiji/maintainer.js b/lib/v2/niaogebiji/maintainer.js index d6faf5c041c94e..904ae5341225b3 100644 --- a/lib/v2/niaogebiji/maintainer.js +++ b/lib/v2/niaogebiji/maintainer.js @@ -1,5 +1,4 @@ module.exports = { - '': ['WenryXu'], '/': ['WenryXu'], '/cat/:cat': ['cKotoriKat'], '/today': ['KotoriK'], diff --git a/lib/v2/qqorw/maintainer.js b/lib/v2/qqorw/maintainer.js index ee544d6c969ccb..8d86e95b45ea72 100644 --- a/lib/v2/qqorw/maintainer.js +++ b/lib/v2/qqorw/maintainer.js @@ -1,4 +1,4 @@ module.exports = { + '/': ['nczitzk'], '/:category?': ['nczitzk'], - '': ['nczitzk'], }; diff --git a/lib/v2/reactnewsletter/maintainer.js b/lib/v2/reactnewsletter/maintainer.js index e9948c57ffa2bc..5e6a04e747cde4 100644 --- a/lib/v2/reactnewsletter/maintainer.js +++ b/lib/v2/reactnewsletter/maintainer.js @@ -1,4 +1,3 @@ module.exports = { - '': ['meixger'], '/': ['meixger'], }; diff --git a/lib/v2/runtrail/maintainer.js b/lib/v2/runtrail/maintainer.js index 13972819d7b162..83fc5ed48db85a 100644 --- a/lib/v2/runtrail/maintainer.js +++ b/lib/v2/runtrail/maintainer.js @@ -1,4 +1,3 @@ module.exports = { - '': ['TonyRL'], '/': ['TonyRL'], }; diff --git a/lib/v2/techpowerup/maintainer.js b/lib/v2/techpowerup/maintainer.js index 388438c4c8a5df..8ed3f79bfe36f9 100644 --- a/lib/v2/techpowerup/maintainer.js +++ b/lib/v2/techpowerup/maintainer.js @@ -1,5 +1,4 @@ module.exports = { - '': ['TonyRL'], '/': ['TonyRL'], '/review/:keyword?': ['TonyRL'], }; diff --git a/lib/v2/tfc-taiwan/maintainer.js b/lib/v2/tfc-taiwan/maintainer.js index 8880ce4c6de637..35f149f7498eb3 100644 --- a/lib/v2/tfc-taiwan/maintainer.js +++ b/lib/v2/tfc-taiwan/maintainer.js @@ -1,5 +1,4 @@ module.exports = { - '': ['TonyRL'], '/': ['TonyRL'], '/:type?': ['TonyRL'], // /info and /report '/:type/:id+': ['TonyRL'], // /category/:id+ and /topic/:id diff --git a/lib/v2/v1tx/maintainer.js b/lib/v2/v1tx/maintainer.js index 13972819d7b162..83fc5ed48db85a 100644 --- a/lib/v2/v1tx/maintainer.js +++ b/lib/v2/v1tx/maintainer.js @@ -1,4 +1,3 @@ module.exports = { - '': ['TonyRL'], '/': ['TonyRL'], }; diff --git a/lib/v2/weekendhk/maintainer.js b/lib/v2/weekendhk/maintainer.js index 13972819d7b162..83fc5ed48db85a 100644 --- a/lib/v2/weekendhk/maintainer.js +++ b/lib/v2/weekendhk/maintainer.js @@ -1,4 +1,3 @@ module.exports = { - '': ['TonyRL'], '/': ['TonyRL'], }; diff --git a/scripts/workflow/test-issue/call-maintainer.js b/scripts/workflow/test-issue/call-maintainer.js index a220e35854b239..24f4e83d45bf0b 100644 --- a/scripts/workflow/test-issue/call-maintainer.js +++ b/scripts/workflow/test-issue/call-maintainer.js @@ -44,6 +44,9 @@ async function parseBodyRoutes(body, core) { } async function getMaintainersByRoutes(routes, core) { + // TODO: change me when https://github.com/actions/github-script is run on node20 + // const response = await fetch(maintainerURL); + // const maintainers = await response.json(); const maintainers = await got(maintainerURL).json(); return routes.map((e) => { diff --git a/scripts/workflow/test-route/identify.js b/scripts/workflow/test-route/identify.js index fb4d0fd48fff2a..5ce02fa9059c47 100644 --- a/scripts/workflow/test-route/identify.js +++ b/scripts/workflow/test-route/identify.js @@ -8,12 +8,12 @@ module.exports = async ({ github, context, core }, body, number, sender) => { core.debug(`match: ${m}`); let res = null; - const issue_facts = { + const issueFacts = { owner: context.repo.owner, repo: context.repo.repo, issue_number: number, }; - const pr_facts = { + const prFacts = { owner: context.repo.owner, repo: context.repo.repo, pull_number: number, @@ -22,7 +22,7 @@ module.exports = async ({ github, context, core }, body, number, sender) => { const addLabels = (labels) => github.rest.issues .addLabels({ - ...issue_facts, + ...issueFacts, labels, }) .catch((e) => { @@ -32,7 +32,7 @@ module.exports = async ({ github, context, core }, body, number, sender) => { const removeLabel = () => github.rest.issues .removeLabel({ - ...issue_facts, + ...issueFacts, name: noFound, }) .catch((e) => { @@ -42,7 +42,7 @@ module.exports = async ({ github, context, core }, body, number, sender) => { const updatePrState = (state) => github.rest.pulls .update({ - ...pr_facts, + ...prFacts, state, }) .catch((e) => { @@ -52,20 +52,28 @@ module.exports = async ({ github, context, core }, body, number, sender) => { const createComment = (body) => github.rest.issues .createComment({ - ...issue_facts, + ...issueFacts, body, }) .catch((e) => { core.warning(e); }); - const createFailedComment = () => - createComment(`自动检测失败,请确认 PR 正文部分符合格式规范并重新开启,详情请检查日志 - Auto Route test failed, please check your PR body format and reopen pull request. Check logs for more details`); + const createFailedComment = () => { + const logUrl = `${process.env.GITHUB_SERVER_URL}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; + + if (process.env.PULL_REQUEST) { + return createComment(`Auto Route Test failed, please check your PR body format and reopen pull request. Check [logs](${logUrl}) for more details. + 自动路由测试失败,请确认 PR 正文部分符合格式规范并重新开启,详情请检查 [日志](${logUrl})。`); + } + + return createComment(`Route Test failed, please check your comment body. Check [logs](${logUrl}) for more details. + 路由测试失败,请确认评论部分符合格式规范,详情请检查 [日志](${logUrl})。`); + }; const pr = await github.rest.issues .get({ - ...issue_facts, + ...issueFacts, }) .catch((e) => { core.warning(e); @@ -102,9 +110,11 @@ module.exports = async ({ github, context, core }, body, number, sender) => { core.warning('Seems like no valid routes can be found. Failing.'); - await addLabels([noFound]); await createFailedComment(); - await updatePrState('closed'); + if (process.env.PULL_REQUEST) { + await addLabels([noFound]); + await updatePrState('closed'); + } throw Error('Please follow the PR rules: failed to detect route'); }; diff --git a/scripts/workflow/test-route/test.js b/scripts/workflow/test-route/test.js index c2807c8e4910a6..bb7978fd8f3031 100644 --- a/scripts/workflow/test-route/test.js +++ b/scripts/workflow/test-route/test.js @@ -17,14 +17,25 @@ module.exports = async ({ github, context, core, got }, baseUrl, routes, number) core.info(`testing route: ${lks}`); // Intended, one at a time let success = false; - let detail = 'no detail'; + let detail; try { + // TODO: change me when https://github.com/actions/github-script is run on node20 + // const res = await fetch(lks); + // if (!res.ok) { + // throw res; + // } + // success = true; + // detail = (await res.text()).replace(/\s+(\n|$)/g, '\n'); const res = await got(lks); if (res && res.body) { success = true; detail = res.body.replace(/\s+(\n|$)/g, '\n'); } } catch (err) { + // TODO: change me when https://github.com/actions/github-script is run on node20 + // detail = `HTTPError: Response code ${err.status} (${err.statusText})`; + // const res = await err.text(); + // const errInfoList = err.body && res.match(/(?<=
)(.+?)(?=<\/pre>)/gs);
             detail = err.toString();
             const errInfoList = err.response && err.response.body && err.response.body.match(/(?<=
)(.+?)(?=<\/pre>)/gs);
             if (errInfoList) {