Skip to content

Commit

Permalink
👷 Docker push to GHCR
Browse files Browse the repository at this point in the history
Also publish to the GitHub Container Registry as a fallback method, fixes #1887
  • Loading branch information
AndreMiras committed Jan 18, 2025
1 parent ffe2dcf commit 55b7142
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
34 changes: 26 additions & 8 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,57 @@ on:
workflow_dispatch:

env:
IMAGE_NAME: kivy/buildozer
DOCKERHUB_IMAGE: kivy/buildozer
GHCR_IMAGE: ghcr.io/${{ github.repository }}
SHOULD_PUBLISH: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')) }}

jobs:
build:
runs-on: ubuntu-24.04
timeout-minutes: 60
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3

# Login to DockerHub
- uses: docker/login-action@v3
if: ${{ env.SHOULD_PUBLISH == 'true' }}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

# Login to GHCR
- uses: docker/login-action@v3
if: ${{ env.SHOULD_PUBLISH == 'true' }}
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push Multi-platform Image
uses: docker/build-push-action@v6
with:
push: ${{ env.SHOULD_PUBLISH == 'true' }}
tags: ${{ env.IMAGE_NAME }}:latest
tags: |
${{ env.DOCKERHUB_IMAGE }}:latest
${{ env.GHCR_IMAGE }}:latest
platforms: linux/amd64,linux/arm64
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:latest
cache-to: ${{ env.SHOULD_PUBLISH == 'true' && format('type=registry,ref={0}:latest,mode=max', env.IMAGE_NAME) || '' }}
cache-from: type=registry,ref=${{ env.DOCKERHUB_IMAGE }}:latest
cache-to: ${{ env.SHOULD_PUBLISH == 'true' && format('type=registry,ref={0}:latest,mode=max', env.DOCKERHUB_IMAGE) || '' }}

- name: Local Build for Testing
uses: docker/build-push-action@v6
with:
# Load image into local Docker daemon
load: true
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:latest
tags: ${{ env.IMAGE_NAME }}:latest
cache-from: type=registry,ref=${{ env.DOCKERHUB_IMAGE }}:latest
tags: ${{ env.DOCKERHUB_IMAGE }}:latest
# Run the locally built image to test it
- name: Docker run
run: docker run ${{ env.IMAGE_NAME }} --version
run: docker run ${{ env.DOCKERHUB_IMAGE }} --version

update-readme:
runs-on: ubuntu-24.04
Expand All @@ -50,5 +68,5 @@ jobs:
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: ${{ env.IMAGE_NAME }}
repository: ${{ env.DOCKERHUB_IMAGE }}
readme-filepath: README.md
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ docker run --volume "$(pwd)":/home/user/hostcwd kivy/buildozer --version
docker run -v $HOME/.buildozer:/home/user/.buildozer -v $(pwd):/home/user/hostcwd kivy/buildozer android debug
```

The image is published to both Docker Hub and GitHub Container Registry and can be pulled from both:

```bash
docker pull kivy/buildozer:latest
docker pull ghcr.io/kivy/buildozer:latest
```

## Buildozer GitHub action

Expand Down

0 comments on commit 55b7142

Please sign in to comment.