Skip to content

Commit 5d6102e

Browse files
authored
Merge pull request #22 from sparkfabrik/fix/docker_login
refs #000: fix docker login action
2 parents b6fafdc + 0ff538b commit 5d6102e

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

.github/workflows/docker-publish.yml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ name: Docker
33
on:
44
push:
55
branches:
6-
- 'main'
6+
- "main"
77
pull_request:
88
branches:
9-
- 'main'
9+
- "main"
1010

1111
env:
1212
IMAGE_NAME: ops-utils
@@ -19,7 +19,7 @@ jobs:
1919

2020
- name: Build image
2121
run: docker build . --file Dockerfile --tag $IMAGE_NAME-test
22-
22+
2323
- name: E2E tests
2424
run: make test
2525

@@ -31,16 +31,21 @@ jobs:
3131
steps:
3232
- uses: actions/checkout@v3
3333

34+
# Refs https://github.com/docker/login-action#github-container-registry
35+
- name: Login to GitHub Container Registry
36+
uses: docker/login-action@v2
37+
with:
38+
registry: ghcr.io
39+
username: ${{ github.actor }}
40+
password: ${{ secrets.GITHUB_TOKEN }}
41+
3442
- name: Build image
3543
run: docker build . --file Dockerfile --tag $IMAGE_NAME
3644

37-
- name: Log into GitHub Container Registry
38-
run: echo "${{ secrets.CR_PAT }}" | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin
39-
4045
- name: Push image to GitHub Container Registry
4146
run: |
4247
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
43-
48+
4449
# Change all uppercase to lowercase.
4550
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
4651
@@ -49,10 +54,10 @@ jobs:
4954
5055
# Strip "v" prefix from tag name.
5156
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
52-
57+
5358
# Use Docker `latest` tag convention.
5459
[ "$VERSION" == "main" ] && VERSION=latest
5560
echo IMAGE_ID=$IMAGE_ID
5661
echo VERSION=$VERSION
5762
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
58-
docker push $IMAGE_ID:$VERSION
63+
docker push $IMAGE_ID:$VERSION

0 commit comments

Comments
 (0)