-
Notifications
You must be signed in to change notification settings - Fork 121
30 lines (28 loc) · 1.07 KB
/
cleanup-docker-pr.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
name: cleanup-docker-pr
on:
pull_request:
types: [closed]
env:
PR_NUMBER: ${{ github.event.number }}
OWNER: orgs/nanocurrency
PACKAGE_NAME: nano-docs
PER_PAGE: 100
jobs:
container_cleanup:
runs-on: ubuntu-latest
steps:
- name: Clean up PR specific container
uses: actions/github-script@d556feaca394842dc55e4734bf3bb9f685482fa0 #v6.3.3
with:
github-token: ${{ secrets.GHCR_TOKEN }}
script: |
const response = await github.request("GET /${{ env.OWNER }}/packages/container/${{ env.PACKAGE_NAME }}/versions",
{ per_page: ${{ env.PER_PAGE }}
});
for(version of response.data) {
if (version.metadata.container.tags[0] == "pr-${{ env.PR_NUMBER }}") {
console.log("delete " + version.id)
const deleteResponse = await github.request("DELETE /${{ env.OWNER }}/packages/container/${{ env.PACKAGE_NAME }}/versions/" + version.id, { });
console.log("status " + deleteResponse.status)
}
}