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