From 09c56a724d5599933d909bc2d19a6d68c09a093d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20Sch=C3=BCtte?= Date: Mon, 16 Dec 2024 11:24:01 +0100 Subject: [PATCH] Switch to ESM --- .github/workflows/test.yml | 2 ++ index.js | 8 ++++---- package.json | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 25e3c6e..03cae86 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,6 +24,8 @@ jobs: node-version: ${{ matrix.version }} cache: 'npm' - run: npm ci + - run: npm run build + - run: cp dist/index.js index.js - uses: ./ with: token: ${{ github.token }} diff --git a/index.js b/index.js index fdf5147..ef208af 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,7 @@ -const core = require('@actions/core'); -const github = require('@actions/github'); -const { Octokit } = require('@octokit/rest'); -const { extract: extractOlderThanInMs, filterWorkflowRuns: filterWorkflowRunsOlderThan} = require('./process_older_than'); +import core from '@actions/core'; +import github from '@actions/github'; +import { Octokit } from '@octokit/rest'; +import { extract as extractOlderThanInMs, filterWorkflowRuns as filterWorkflowRunsOlderThan} from './process_older_than.js'; const getInput = (name, fallback = undefined, extractor = (data) => data) => { try { diff --git a/package.json b/package.json index 2668850..e745865 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "purge-deprecated-workflow-runs", "description": "Delete github workflow runs that don't have a corresponding workflow (anymore) from the current repository. Optionally delete cancelled, failed or skipped workflow runs.", "main": "dist/index.js", + "type": "module", "scripts": { "build": "npx @vercel/ncc build", "postbuild": "sed 's+index.js+dist/index.js+g' action.yml > action.yml.built && mv action.yml.built action.yml",