I went with OP's method of a string input that is split into an array. I use a comma-separated string.
Call it in a step:
- name: delete artifacts
uses: my-org/my-actions/actions/utility/delete-artifact@v0
with:
name: "scripts, event"
continue-on-error: true
The Action implementation:
# action.yaml
inputs:
name:
description: The name of the artifact(s) to delete. Comma separate multiple names.
required: true
runs:
using: node20
main: dist/index.js
// index.ts
import { deleteArtifact } from './main';
import { getInput, setFailed } from '@actions/core';
async function deleteArtifacts() {
// validate Action input is not empty
let names: string | string[] = getInput('name')
if (names) {
names = names.split(',').map(name => name.trim());
}
else {
setFailed('No artifact names provided');
}
// if the input is valid, loop over the inputs and delete the artifacts
for (const name of names) {
deleteArtifact(name);
}
}
deleteArtifacts();
// main.ts
import { DefaultArtifactClient } from '@actions/artifact';
import { info } from '@actions/core';
export async function deleteArtifact(name: string) {
const artifact: DefaultArtifactClient = new DefaultArtifactClient();
try {
info(`Deleting artifact: ${name}`);
await artifact.deleteArtifact(name);
}
catch (error) {
info(`${(error as {message: string}).message}`);
}
}