-
Notifications
You must be signed in to change notification settings - Fork 4
62 lines (58 loc) · 1.82 KB
/
poc-workflow.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
name: poc CI
on:
push:
branches: [master]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Drop the command tag
uses: actions/[email protected]
with:
github-token: ${{secrets.GITHUB_TOKEN}}
# Cf. https://octokit.github.io/rest.js/
script: |
packages = await github.graphql(`
{
repository(name: "github-actions-poc", owner: "adnovum") {
registryPackagesForQuery(first: 100) {
edges {
node {
id,name, versions(first:100){
edges {
node {
id,version,updatedAt
}
}
}
}
}
}
}
}
`)
let cutoff = new Date(new Date().getTime() - 30 * 86400000)
console.log(cutoff)
pkgVersionsToDelete = []
for (let pkg of packages.repository.registryPackagesForQuery.edges) {
for (let ver of pkg.node.versions.edges) {
let dt = new Date(ver.node.updatedAt)
if (dt <= cutoff) {
pkgVersionsToDelete.push(ver.node.id)
}
}
}
console.log(pkgVersionsToDelete)
deleteSuccess = await github.graphql(`
mutation {
deletePackageVersion(input:{packageVersionId:"MDE0OlBhY2thZ2VWZXJzaW9uNDU5OTY3"}) {
success
}
}
`,
{
headers: {
accept: "application/vnd.github.package-deletes-preview+json"
}
})
console.log(deleteSuccess)