Skip to content

Commit

Permalink
Switch to ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
hanseartic committed Dec 16, 2024
1 parent f21da18 commit 2c88b8e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
node-version: ${{ matrix.version }}
cache: 'npm'
- run: npm ci
- run: npm run build
- uses: ./
with:
token: ${{ github.token }}
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 2 additions & 7 deletions process_older_than.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const durationUnitToMs = {
y: 31536000000,
}

const extract = (data) => {
export const extract = (data) => {
const [since, ...nameSlices] = data.split(' ')
const workflowName = nameSlices.length
? nameSlices.join(' ')
Expand All @@ -26,7 +26,7 @@ const extract = (data) => {
}
}

const filterWorkflowRuns = (workflowRuns, extractedOlderThanList) => {
export const filterWorkflowRuns = (workflowRuns, extractedOlderThanList) => {
const now = new Date()
const olderThan = extractedOlderThanList
.map((since) => ({
Expand All @@ -44,8 +44,3 @@ const filterWorkflowRuns = (workflowRuns, extractedOlderThanList) => {
})
)
}

module.exports = {
extract,
filterWorkflowRuns,
}

0 comments on commit 2c88b8e

Please sign in to comment.