File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Publish
2
+
3
+ on :
4
+ push :
5
+ branches :
6
+ - main
7
+ tags :
8
+ - " v*"
9
+
10
+ env :
11
+ IMAGE_NAME : agg
12
+
13
+ jobs :
14
+ publish :
15
+ runs-on : ubuntu-22.04
16
+ permissions :
17
+ packages : write
18
+ contents : read
19
+
20
+ steps :
21
+ - uses : actions/checkout@v3
22
+
23
+ - name : Build image
24
+ run : docker build . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
25
+
26
+ - name : Log in to registry
27
+ run : echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
28
+
29
+ - name : Push image
30
+ run : |
31
+ IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
32
+
33
+ # Change all uppercase to lowercase
34
+ IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
35
+ # Strip git ref prefix from version
36
+ VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
37
+ # Strip "v" prefix from tag name
38
+ [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
39
+ # Use Docker `latest` tag convention
40
+ [ "$VERSION" == "main" ] && VERSION=latest
41
+ echo IMAGE_ID=$IMAGE_ID
42
+ echo VERSION=$VERSION
43
+ docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
44
+ docker push $IMAGE_ID:$VERSION
You can’t perform that action at this time.
0 commit comments