Skip to content

Commit 369ff57

Browse files
committed
👷 Docker workflow fixes
- fix `github.ref` for DockerHub publish on push to develop - fix docker login to handle special characters in the token - publish docker tag to DockerHub on git tagging
1 parent 08713b3 commit 369ff57

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

.github/workflows/docker.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ on:
55
push:
66
branches:
77
- develop
8+
tags:
9+
- "*"
810
pull_request:
911

1012
jobs:
@@ -14,11 +16,18 @@ jobs:
1416
- uses: actions/checkout@v4
1517
- uses: docker/setup-buildx-action@v3
1618
- run: make docker/build
19+
- name: docker login
20+
if: github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/')
1721
env:
1822
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
1923
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
24+
run: make docker/login
2025
- name: docker push
21-
if: github.ref == 'develop'
26+
if: github.ref == 'refs/heads/develop'
27+
run: make docker/push
28+
run: echo make docker/push
29+
- name: docker push (tag)
30+
if: startsWith(github.ref, 'refs/tags/')
2231
run: |
23-
make docker/login
32+
make docker/tag DOCKER_TAG=${GITHUB_REF#refs/tags/}
2433
make docker/push

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ TOX=`which tox`
44
ACTIVATE=$(VIRTUAL_ENV)/bin/activate
55
PYTHON=$(VIRTUAL_ENV)/bin/python
66
DOCKER_IMAGE=kivy/python-for-android
7+
DOCKER_TAG=latest
78
ANDROID_SDK_HOME ?= $(HOME)/.android/android-sdk
89
ANDROID_NDK_HOME ?= $(HOME)/.android/android-ndk
910
ANDROID_NDK_HOME_LEGACY ?= $(HOME)/.android/android-ndk-legacy
@@ -118,10 +119,13 @@ docker/build:
118119
docker build --cache-from=$(DOCKER_IMAGE) --tag=$(DOCKER_IMAGE) .
119120

120121
docker/login:
121-
@echo $(DOCKERHUB_TOKEN) | docker login --username $(DOCKERHUB_USERNAME) --password-stdin
122+
@echo $$DOCKERHUB_TOKEN | docker login --username $(DOCKERHUB_USERNAME) --password-stdin
123+
124+
docker/tag:
125+
docker tag $(DOCKER_IMAGE):latest $(DOCKER_IMAGE):$(DOCKER_TAG)
122126

123127
docker/push:
124-
docker push $(DOCKER_IMAGE)
128+
docker push $(DOCKER_IMAGE):$(DOCKER_TAG)
125129

126130
docker/run/test: docker/build
127131
docker run --rm --env-file=.env $(DOCKER_IMAGE) 'make test'

0 commit comments

Comments
 (0)