Skip to content

Commit

Permalink
Merge pull request #3067 from AndreMiras/feature/docker_workflow_fixes
Browse files Browse the repository at this point in the history
👷 Docker workflow fixes
  • Loading branch information
AndreMiras authored Oct 1, 2024
2 parents 08713b3 + 369ff57 commit c88cf13
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
push:
branches:
- develop
tags:
- "*"
pull_request:

jobs:
Expand All @@ -14,11 +16,18 @@ jobs:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- run: make docker/build
- name: docker login
if: github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/')
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
run: make docker/login
- name: docker push
if: github.ref == 'develop'
if: github.ref == 'refs/heads/develop'
run: make docker/push
run: echo make docker/push
- name: docker push (tag)
if: startsWith(github.ref, 'refs/tags/')
run: |
make docker/login
make docker/tag DOCKER_TAG=${GITHUB_REF#refs/tags/}
make docker/push
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ TOX=`which tox`
ACTIVATE=$(VIRTUAL_ENV)/bin/activate
PYTHON=$(VIRTUAL_ENV)/bin/python
DOCKER_IMAGE=kivy/python-for-android
DOCKER_TAG=latest
ANDROID_SDK_HOME ?= $(HOME)/.android/android-sdk
ANDROID_NDK_HOME ?= $(HOME)/.android/android-ndk
ANDROID_NDK_HOME_LEGACY ?= $(HOME)/.android/android-ndk-legacy
Expand Down Expand Up @@ -118,10 +119,13 @@ docker/build:
docker build --cache-from=$(DOCKER_IMAGE) --tag=$(DOCKER_IMAGE) .

docker/login:
@echo $(DOCKERHUB_TOKEN) | docker login --username $(DOCKERHUB_USERNAME) --password-stdin
@echo $$DOCKERHUB_TOKEN | docker login --username $(DOCKERHUB_USERNAME) --password-stdin

docker/tag:
docker tag $(DOCKER_IMAGE):latest $(DOCKER_IMAGE):$(DOCKER_TAG)

docker/push:
docker push $(DOCKER_IMAGE)
docker push $(DOCKER_IMAGE):$(DOCKER_TAG)

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

0 comments on commit c88cf13

Please sign in to comment.