1
1
---
2
2
name : Publish Docker
3
3
4
+ # Allow publishing dev images from open PRs
5
+ permissions :
6
+ packages : write
7
+
4
8
on :
5
9
push :
10
+ branches :
11
+ - main
12
+ pull_request :
6
13
7
14
env :
8
- IMAGE_TAG : ghcr.io/${{ github.repository_owner }}/zeusops-bot:latest
15
+ IMAGE_NAME : ghcr.io/${{ github.repository_owner }}/zeusops-bot
9
16
10
17
jobs :
11
18
build :
@@ -14,10 +21,10 @@ jobs:
14
21
steps :
15
22
- uses : actions/checkout@master
16
23
- name : Login to GitHub Container Registry
17
- uses : docker/login-action@v1
24
+ uses : docker/login-action@v3
18
25
with :
19
26
registry : ghcr.io
20
- username : ${{ github.repository_owner }}
27
+ username : ${{ github.actor }}
21
28
password : ${{ secrets.GITHUB_TOKEN }}
22
29
- name : Build Image
23
30
run : docker build -f release.Dockerfile -t zeusops-bot .
@@ -30,27 +37,31 @@ jobs:
30
37
if-no-files-found : error
31
38
retention-days : 7
32
39
33
- main_publish :
40
+ publish :
34
41
name : Publish Image
35
42
runs-on : ubuntu-latest
36
43
needs :
37
44
- build
38
- if : github.ref == 'refs/heads/main'
39
45
steps :
46
+ - name : Create Release Image Name
47
+ if : github.ref == 'refs/heads/main'
48
+ run : |
49
+ echo "IMAGE_TAG_LOWER=${IMAGE_NAME@L}:latest" >> "${GITHUB_ENV}"
50
+ - name : Create PR Image Name
51
+ if : github.event_name == 'pull_request'
52
+ run : |
53
+ echo "IMAGE_TAG_LOWER=${IMAGE_NAME@L}:dev-pr-${{ github.event.number }}" >> "${GITHUB_ENV}"
40
54
- name : Login to GHCR
41
- uses : docker/login-action@v1
55
+ uses : docker/login-action@v3
42
56
with :
43
57
registry : ghcr.io
44
- username : ${{ github.repository_owner }}
58
+ username : ${{ github.actor }}
45
59
password : ${{ secrets.GITHUB_TOKEN }}
46
60
- uses : actions/download-artifact@v4
47
61
with :
48
62
name : image
49
63
- name : Load Image
50
64
run : docker load < image.tar.gz
51
- - name : lowercase repo
52
- run : |
53
- echo "IMAGE_TAG_LOWER=${IMAGE_TAG@L}" >> "${GITHUB_ENV}"
54
65
- name : Tag Image
55
66
run : docker tag zeusops-bot "$IMAGE_TAG_LOWER"
56
67
- name : Push Image
0 commit comments