|
6 | 6 | workflow_dispatch: |
7 | 7 |
|
8 | 8 | env: |
9 | | - IMAGE_NAME: kivy/buildozer |
10 | | - SHOULD_PUBLISH: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')) }} |
| 9 | + DOCKERHUB_IMAGE: kivy/buildozer |
| 10 | + GHCR_IMAGE: ghcr.io/${{ github.repository }} |
| 11 | + # TODO |
| 12 | + # SHOULD_PUBLISH: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')) }} |
| 13 | + SHOULD_PUBLISH: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/feature/github_container_registry' || startsWith(github.ref, 'refs/tags/')) }} |
11 | 14 |
|
12 | 15 | jobs: |
13 | 16 | build: |
14 | 17 | runs-on: ubuntu-24.04 |
15 | 18 | timeout-minutes: 60 |
| 19 | + permissions: |
| 20 | + contents: read |
| 21 | + packages: write |
16 | 22 | steps: |
17 | 23 | - uses: actions/checkout@v4 |
18 | 24 | - uses: docker/setup-buildx-action@v3 |
| 25 | + |
| 26 | + # Login to DockerHub |
19 | 27 | - uses: docker/login-action@v3 |
20 | 28 | if: ${{ env.SHOULD_PUBLISH == 'true' }} |
21 | 29 | with: |
22 | 30 | username: ${{ secrets.DOCKERHUB_USERNAME }} |
23 | 31 | password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 32 | + |
| 33 | + # Login to GHCR |
| 34 | + - uses: docker/login-action@v3 |
| 35 | + if: ${{ env.SHOULD_PUBLISH == 'true' }} |
| 36 | + with: |
| 37 | + registry: ghcr.io |
| 38 | + username: ${{ github.actor }} |
| 39 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 40 | + |
24 | 41 | - name: Build and Push Multi-platform Image |
25 | 42 | uses: docker/build-push-action@v6 |
26 | 43 | with: |
27 | 44 | push: ${{ env.SHOULD_PUBLISH == 'true' }} |
28 | | - tags: ${{ env.IMAGE_NAME }}:latest |
| 45 | + tags: | |
| 46 | + ${{ env.DOCKERHUB_IMAGE }}:latest |
| 47 | + ${{ env.GHCR_IMAGE }}:latest |
29 | 48 | platforms: linux/amd64,linux/arm64 |
30 | | - cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:latest |
31 | | - cache-to: ${{ env.SHOULD_PUBLISH == 'true' && format('type=registry,ref={0}:latest,mode=max', env.IMAGE_NAME) || '' }} |
| 49 | + cache-from: type=registry,ref=${{ env.DOCKERHUB_IMAGE }}:latest |
| 50 | + cache-to: ${{ env.SHOULD_PUBLISH == 'true' && format('type=registry,ref={0}:latest,mode=max', env.DOCKERHUB_IMAGE) || '' }} |
| 51 | + |
32 | 52 | - name: Local Build for Testing |
33 | 53 | uses: docker/build-push-action@v6 |
34 | 54 | with: |
35 | 55 | # Load image into local Docker daemon |
36 | 56 | load: true |
37 | | - cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:latest |
38 | | - tags: ${{ env.IMAGE_NAME }}:latest |
| 57 | + cache-from: type=registry,ref=${{ env.DOCKERHUB_IMAGE }}:latest |
| 58 | + tags: ${{ env.DOCKERHUB_IMAGE }}:latest |
39 | 59 | # Run the locally built image to test it |
40 | 60 | - name: Docker run |
41 | | - run: docker run ${{ env.IMAGE_NAME }} --version |
| 61 | + run: docker run ${{ env.DOCKERHUB_IMAGE }} --version |
42 | 62 |
|
43 | 63 | update-readme: |
44 | 64 | runs-on: ubuntu-24.04 |
|
50 | 70 | with: |
51 | 71 | username: ${{ secrets.DOCKERHUB_USERNAME }} |
52 | 72 | password: ${{ secrets.DOCKERHUB_TOKEN }} |
53 | | - repository: ${{ env.IMAGE_NAME }} |
| 73 | + repository: ${{ env.DOCKERHUB_IMAGE }} |
54 | 74 | readme-filepath: README.md |
0 commit comments