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