-
Notifications
You must be signed in to change notification settings - Fork 0
47 lines (42 loc) · 1.41 KB
/
build.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
name: Build
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: "recursive"
- name: Login to Github Container Registry
run: echo ${{ secrets.GHCR_PAT }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build Docker Image
run: docker build -t ghcr.io/sharknoon/pixina .
- name: Push Image to Registry
run: docker push ghcr.io/sharknoon/pixina
clean:
needs: build
runs-on: ubuntu-latest
steps:
- name: Delete untagged Images
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GHCR_PAT }}
script: |
const response = await github.request("GET /user/packages/container/${{ env.PACKAGE_NAME }}/versions",
{
per_page: ${{ env.PER_PAGE }}
}
);
for(version of response.data) {
if (version.metadata.container.tags.length == 0) {
console.log("Deleting " + version.id)
const deleteResponse = await github.request("DELETE /user/packages/container/${{ env.PACKAGE_NAME }}/versions/" + version.id, { });
console.log("Deleted " + deleteResponse.status)
}
}
env:
PACKAGE_NAME: pixina
PER_PAGE: 100