-
Notifications
You must be signed in to change notification settings - Fork 0
45 lines (38 loc) · 1.23 KB
/
buildAndPushImage.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
name: buildAndPushImage
on:
push:
branches:
- 'main'
- 'dev'
pull_request:
branches:
- 'main'
env:
IMAGE_URL: ghcr.io/ust-demaf
IMAGE_NAME: models-service
IMAGE_TAG: ${{ github.ref == 'refs/heads/main' && 'latest' || 'testing' }}
jobs:
build-using-dockerfile-push-2-ghcr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Login to GitHub Container Registry
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u well5a --password-stdin
- name: Build the Docker image
run: docker build . --file Dockerfile --tag $IMAGE_URL/$IMAGE_NAME:$IMAGE_TAG
- name: Push the Docker image
run: docker push $IMAGE_URL/$IMAGE_NAME:$IMAGE_TAG
delete-untagged-images:
needs:
- build-using-dockerfile-push-2-ghcr
runs-on: ubuntu-latest
steps:
- uses: actions/delete-package-versions@v5
with:
owner: ${{ github.repository_owner }}
package-name: ${{ env.IMAGE_NAME }}
package-type: "container"
token: ${{ secrets.GITHUB_TOKEN }}
min-versions-to-keep: 3
delete-only-pre-release-versions: "true"
delete-only-untagged-versions: "true"