Skip to content

Commit 82c0ccc

Browse files
authored
Update docker-publish.yml
1 parent 563bb7a commit 82c0ccc

1 file changed

Lines changed: 32 additions & 39 deletions

File tree

Lines changed: 32 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,19 @@
11
name: Docker
2-
3-
on:
2+
'on':
43
push:
5-
# Publish `master` as Docker `latest` image.
64
branches:
75
- ci
8-
9-
# Publish `v1.2.3` tags as releases.
6+
- master
107
tags:
118
- v*
12-
13-
# Run tests for any PRs.
14-
pull_request:
15-
9+
pull_request: null
1610
env:
17-
# TODO: Change variable to your image's name.
18-
IMAGE_NAME: strimlitapp
19-
11+
IMAGE_NAME: strimlitapp
2012
jobs:
21-
# Run tests.
22-
# See also https://docs.docker.com/docker-hub/builds/automated-testing/
2313
test:
2414
runs-on: ubuntu-latest
25-
2615
steps:
2716
- uses: actions/checkout@v2
28-
2917
- name: Run tests
3018
run: |
3119
if [ -f docker-compose.test.yml ]; then
@@ -34,42 +22,47 @@ jobs:
3422
else
3523
docker build . --file Dockerfile
3624
fi
37-
# Push image to GitHub Packages.
38-
# See also https://docs.docker.com/docker-hub/builds/
3925
push:
40-
# Ensure test job passes before pushing image.
4126
needs: test
42-
4327
runs-on: ubuntu-latest
4428
if: github.event_name == 'push'
45-
4629
steps:
4730
- uses: actions/checkout@v2
48-
4931
- name: Build image
5032
run: docker build . --file Dockerfile --tag $IMAGE_NAME
33+
- name: Log into registry
34+
run: >-
35+
echo "${{ secrets.GITHUB_TOKEN }}" | docker login
36+
docker.pkg.github.com -u ${{ github.actor }} --password-stdin
37+
- name: Push image
38+
run: >
39+
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME
40+
41+
# Change all uppercase to lowercase
42+
43+
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
44+
45+
# Strip git ref prefix from version
46+
47+
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
48+
49+
50+
# Strip "v" prefix from tag name
51+
52+
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION
53+
| sed -e 's/^v//')
54+
5155
52-
- name: Log into registry
53-
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
56+
# Use Docker `latest` tag convention
5457
55-
- name: Push image
56-
run: |
57-
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME
58+
[ "$VERSION" == "master" ] && VERSION=latest
5859
59-
# Change all uppercase to lowercase
60-
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
6160
62-
# # Strip git ref prefix from version
63-
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
61+
echo IMAGE_ID=$IMAGE_ID
6462
65-
# # Strip "v" prefix from tag name
66-
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
63+
echo VERSION=$VERSION
6764
68-
# # Use Docker `latest` tag convention
69-
[ "$VERSION" == "master" ] && VERSION=latest
7065
71-
echo IMAGE_ID=$IMAGE_ID
72-
echo VERSION=$VERSION
66+
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
7367
74-
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
75-
docker push $IMAGE_ID:$VERSION
68+
docker push $IMAGE_ID:$VERSION

0 commit comments

Comments
 (0)