|
6 | 6 | - 'master'
|
7 | 7 | schedule:
|
8 | 8 | # Daily
|
9 |
| - - cron: '0 0 * * *' |
| 9 | + - cron: '0 4 * * *' |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +env: |
| 13 | + DOCKERHUB_REPO: frolvlad/alpine-openjdk |
10 | 14 |
|
11 | 15 | jobs:
|
12 |
| - docker: |
13 |
| - runs-on: ubuntu-latest |
| 16 | + build: |
| 17 | + strategy: |
| 18 | + fail-fast: false |
| 19 | + matrix: |
| 20 | + include: |
| 21 | + - platform: linux/amd64 |
| 22 | + os: ubuntu-24.04 |
| 23 | + - platform: linux/arm64 |
| 24 | + os: ubuntu-24.04-arm |
| 25 | + runs-on: ${{ matrix.os }} |
14 | 26 | steps:
|
15 |
| - - |
16 |
| - name: Set up QEMU |
17 |
| - uses: docker/setup-qemu-action@v2 |
18 |
| - - |
19 |
| - name: Set up Docker Buildx |
20 |
| - uses: docker/setup-buildx-action@v2 |
21 |
| - - |
22 |
| - name: Login to Docker Hub |
23 |
| - uses: docker/login-action@v2 |
| 27 | + - name: Prepare |
| 28 | + run: | |
| 29 | + platform=${{ matrix.platform }} |
| 30 | + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV |
| 31 | +
|
| 32 | + - name: Docker meta |
| 33 | + id: meta |
| 34 | + uses: docker/metadata-action@v5 |
| 35 | + with: |
| 36 | + images: | |
| 37 | + ${{ env.DOCKERHUB_REPO }} |
| 38 | + labels: | |
| 39 | + org.opencontainers.image.created={{commit_date 'YYYY-MM-DDTHH:mm:ss.SSS[Z]'}} |
| 40 | +
|
| 41 | + - name: Login to Docker Hub |
| 42 | + uses: docker/login-action@v3 |
24 | 43 | with:
|
25 |
| - username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 44 | + username: ${{ vars.DOCKERHUB_USERNAME }} |
26 | 45 | password: ${{ secrets.DOCKERHUB_TOKEN }}
|
27 |
| - - |
28 |
| - name: Build and push |
29 |
| - uses: docker/build-push-action@v3 |
| 46 | + |
| 47 | + - name: Set up Docker Buildx |
| 48 | + uses: docker/setup-buildx-action@v3 |
| 49 | + |
| 50 | + - name: Build and push by digest |
| 51 | + id: build |
| 52 | + uses: docker/build-push-action@v6 |
30 | 53 | with:
|
31 |
| - pull: true |
| 54 | + platforms: ${{ matrix.platform }} |
| 55 | + labels: ${{ steps.meta.outputs.labels }} |
| 56 | + outputs: type=image,"name=${{ env.DOCKERHUB_REPO }}",push-by-digest=true,name-canonical=true,push=true |
32 | 57 | push: true
|
33 |
| - tags: frolvlad/alpine-openjdk:latest |
34 |
| - cache-from: type=registry,ref=frolvlad/alpine-openjdk:latest |
35 |
| - cache-to: type=inline |
| 58 | + cache-from: type=registry,ref=${{ env.DOCKERHUB_REPO }}:buildcache-${{ env.PLATFORM_PAIR }} |
| 59 | + cache-to: type=registry,ref=${{ env.DOCKERHUB_REPO }}:buildcache-${{ env.PLATFORM_PAIR }},mode=max |
| 60 | + |
| 61 | + - name: Export digest |
| 62 | + run: | |
| 63 | + mkdir -p ${{ runner.temp }}/digests |
| 64 | + digest="${{ steps.build.outputs.digest }}" |
| 65 | + touch "${{ runner.temp }}/digests/${digest#sha256:}" |
| 66 | +
|
| 67 | + - name: Upload digest |
| 68 | + uses: actions/upload-artifact@v4 |
| 69 | + with: |
| 70 | + name: digests-${{ env.PLATFORM_PAIR }} |
| 71 | + path: ${{ runner.temp }}/digests/* |
| 72 | + if-no-files-found: error |
| 73 | + retention-days: 1 |
| 74 | + |
| 75 | + merge: |
| 76 | + runs-on: ubuntu-latest |
| 77 | + needs: |
| 78 | + - build |
| 79 | + steps: |
| 80 | + - name: Download digests |
| 81 | + uses: actions/download-artifact@v4 |
| 82 | + with: |
| 83 | + path: ${{ runner.temp }}/digests |
| 84 | + pattern: digests-* |
| 85 | + merge-multiple: true |
| 86 | + |
| 87 | + - name: Login to Docker Hub |
| 88 | + uses: docker/login-action@v3 |
| 89 | + with: |
| 90 | + username: ${{ vars.DOCKERHUB_USERNAME }} |
| 91 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 92 | + |
| 93 | + - name: Set up Docker Buildx |
| 94 | + uses: docker/setup-buildx-action@v3 |
| 95 | + |
| 96 | + - name: Create manifest list and push |
| 97 | + working-directory: ${{ runner.temp }}/digests |
| 98 | + run: | |
| 99 | + docker buildx imagetools create \ |
| 100 | + -t ${{ env.DOCKERHUB_REPO }}:latest \ |
| 101 | + $(printf '${{ env.DOCKERHUB_REPO }}@sha256:%s ' *) |
| 102 | +
|
| 103 | + - name: Inspect image |
| 104 | + run: | |
| 105 | + docker buildx imagetools inspect ${{ env.DOCKERHUB_REPO }}:latest |
0 commit comments