Skip to content

Automatically delete temporary artifacts sample #1

Automatically delete temporary artifacts sample

Automatically delete temporary artifacts sample #1

name: Automatically delete temporary artifacts sample
on:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
jobs:
remain:
runs-on: ubuntu-22.04
timeout-minutes: 3
steps:
- run: echo "remain" > sample-remain.txt
- uses: actions/upload-artifact@v4
with:
name: sample-remain
path: sample-remain.txt
auto-delete:
runs-on: ubuntu-22.04
timeout-minutes: 3
permissions:
contents: write
steps:
- run: echo "auto-delete" > sample-delete.txt
- uses: actions/upload-artifact@v4
id: upload
with:
name: sample-delete
path: sample-delete.txt
- name: Delete upload artifact
env:
GH_TOKEN: ${{ github.token }}
ID: ${{ steps.upload.outputs.artifact-id }}
REPO: ${{ github.repository }}
run: |
gh api --method DELETE -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" "/repos/${REPO}/actions/artifacts/${ID}"