Skip to content

Commit

Permalink
feat: adds support for actions/upload-artifact@v4 (#17) (fixed #14)
Browse files Browse the repository at this point in the history
* feat: add support for upload-artifact@v4, deprecates support for previous versions
* chore: update docs, fix CI workflow
* docs: fix example
* docs: add deprecation note
* docs: add token note

---------

Co-authored-by: Richard Herman <geekyeggo@users.noreply.github.com>
  • Loading branch information
GeekyEggo and GeekyEggo committed Dec 24, 2023
1 parent dc8092f commit 1b63f0e
Show file tree
Hide file tree
Showing 17 changed files with 31,446 additions and 3,188 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ end_of_line = crlf
indent_style = space
indent_size = 4

[{.yml}]
[*.yml]
indent_style = space
indent_size = 2
86 changes: 43 additions & 43 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,56 @@ name: CI
on:
push:
branches:
- master
- main

defaults:
run:
shell: bash

jobs:
test:
runs-on: windows-latest
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Create test file
run: echo hello > world.txt

- uses: actions/upload-artifact@v4
with:
name: my-artifact
path: world.txt

- uses: actions/upload-artifact@v4
with:
name: my-artifact-2
path: world.txt

- uses: actions/upload-artifact@v4
with:
name: my-artifact-3
path: world.txt

- uses: actions/upload-artifact@v4
with:
name: you-artifact
path: world.txt

- name: Delete (specific, glob disabled)
uses: ./
with:
name: my-artifact
useGlob: false

- name: Delete (pattern, glob enabled)
uses: ./
with:
name: my-*

- name: Delete (specific, glob enabled)
uses: ./
with:
name: you-artifact

- name: Checkout
uses: actions/checkout@v2

- name: Create test file
run: echo hello > world.txt

- uses: actions/upload-artifact@v2
with:
name: my-artifact
path: world.txt

- uses: actions/upload-artifact@v2
with:
name: my-artifact-2
path: world.txt

- uses: actions/upload-artifact@v2
with:
name: my-artifact-3
path: world.txt

- uses: actions/upload-artifact@v2
with:
name: you-artifact
path: world.txt

- name: Delete (specific, glob disabled)
uses: ./
with:
name: my-artifact
useGlob: false

- name: Delete (pattern, glob enabled)
uses: ./
with:
name: my-*

- name: Delete (specific, glob enabled)
uses: ./
with:
name: you-artifact
87 changes: 43 additions & 44 deletions .github/workflows/example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Example

on:
schedule:
- cron: '0 */6 * * *'
- cron: "0 */6 * * *"
# every 6 hours

defaults:
Expand All @@ -12,48 +12,47 @@ defaults:

jobs:
test:
runs-on: windows-latest
runs-on: ubuntu-latest

steps:

- name: Checkout
uses: actions/checkout@v2

- name: Create test file
run: echo hello > world.txt

- uses: actions/upload-artifact@v2
with:
name: my-artifact
path: world.txt

- uses: actions/upload-artifact@v2
with:
name: my-artifact-2
path: world.txt

- uses: actions/upload-artifact@v2
with:
name: my-artifact-3
path: world.txt

- uses: actions/upload-artifact@v2
with:
name: you-artifact
path: world.txt

- name: Delete (specific, glob disabled)
uses: geekyeggo/delete-artifact@v2
with:
name: my-artifact
useGlob: false

- name: Delete (pattern, glob enabled)
uses: geekyeggo/delete-artifact@v2
with:
name: my-*

- name: Delete (specific, glob enabled)
uses: geekyeggo/delete-artifact@v2
with:
name: you-artifact
- name: Checkout
uses: actions/checkout@v2

- name: Create test file
run: echo hello > world.txt

- uses: actions/upload-artifact@v2
with:
name: my-artifact
path: world.txt

- uses: actions/upload-artifact@v2
with:
name: my-artifact-2
path: world.txt

- uses: actions/upload-artifact@v2
with:
name: my-artifact-3
path: world.txt

- uses: actions/upload-artifact@v2
with:
name: you-artifact
path: world.txt

- name: Delete (specific, glob disabled)
uses: geekyeggo/delete-artifact@v2
with:
name: my-artifact
useGlob: false

- name: Delete (pattern, glob enabled)
uses: geekyeggo/delete-artifact@v2
with:
name: my-*

- name: Delete (specific, glob enabled)
uses: geekyeggo/delete-artifact@v2
with:
name: you-artifact
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!--
## {version}
🚨 Break
✨ Add
🐞 Fix
♻️ Update
-->

# Change Log

## v4.0

- Add support for artifacts uploaded with `actions/upload-artifact@v4`.
- Add requirement of `token` with read and write access to actions.
- Update requests to use GitHub REST API.
- Deprecate support for `actions/upload-artifact@v1`, `actions/upload-artifact@v2`, and `actions/upload-artifact@v3` (please use `geekyeggo/delete-artifact@v2`).

## v2.0

- Add support for glob pattern matching via `useGlob`.

## v1.0

- Initial release.

35 changes: 21 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,48 @@

A GitHub Action for deleting artifacts within the workflow run. This can be useful when artifacts are shared across jobs, but are no longer needed when the workflow is complete.

## ✅ Compatibility

| `actions/upload-artifact` | `geekyeggo/delete-artifact` |
| ------------------------- | --------------------------- |
| `@v1`, `@v2`, `@v3` | `@v1`, `@v2` |
| `@v4` | `@v4` |

## ⚡ Usage

See [action.yml](action.yml)

> **Warning**
> From version 2 onwards, glob (wildcard) support is on by default, and is fulfilled by [minimatch](https://www.npmjs.com/package/minimatch); this can be disabled by setting `useGlob` to `false`.
> [!IMPORTANT]
> Support for `actions/upload-artifact@v4` utilizes GitHub's REST API, and requires a token with read and write access to actions.
### Delete an individual artifact

```yml
steps:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v4

- run: echo hello > world.txt
- name: Create test file
run: echo hello > test.txt

- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: my-artifact
path: world.txt
path: test.txt

# delete-artifact
- uses: geekyeggo/delete-artifact@v2
- uses: geekyeggo/delete-artifact@v4
with:
token: ${{ secrets.TOKEN }}
name: my-artifact
```
### Specify multiple names
```yml
steps:
- uses: geekyeggo/delete-artifact@v2
- uses: geekyeggo/delete-artifact@v4
with:
token: ${{ secrets.TOKEN }}
name: |
artifact-*
binary-file
Expand All @@ -49,13 +59,10 @@ By default, the action will fail when it was not possible to delete an artifact
```yml
steps:
- uses: geekyeggo/delete-artifact@v2
- uses: geekyeggo/delete-artifact@v4
with:
token: ${{ secrets.TOKEN }}
name: okay-to-keep
failOnError: false
```
## ⚠ Disclaimer
This action utilizes a preview version of GitHub's runtime API; the API is subject to change at any time which may result in failures of this action.
10 changes: 7 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@ inputs:
name:
description: The name of the artifact to delete; multiple names can be supplied on new lines.
required: true
token:
description: GitHub token with read and write access to actions for the repository.
required: true
useGlob:
description: Indicates whether the name, or names, should be treated as glob patterns.
required: false
default: 'true'
default: "true"
failOnError:
description: Indicates whether the action should fail upon encountering an error.
required: false
default: 'true'
default: "true"
runs:
using: node16
using: node20
main: ./dist/index.js
branding:
icon: trash-2
color: red

Loading

0 comments on commit 1b63f0e

Please sign in to comment.