2021-09-30 23:09:12 +09:00
|
|
|
name: Publish Docker image (develop)
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- develop
|
|
|
|
workflow_dispatch:
|
|
|
|
|
2024-02-16 14:20:17 +09:00
|
|
|
env:
|
2024-02-21 15:34:24 +09:00
|
|
|
REGISTRY_IMAGE: noridev/cherrypick
|
2024-02-16 14:20:17 +09:00
|
|
|
|
2021-09-30 23:09:12 +09:00
|
|
|
jobs:
|
2024-02-16 14:20:17 +09:00
|
|
|
# see https://docs.docker.com/build/ci/github-actions/multi-platform/#distribute-build-across-multiple-runners
|
|
|
|
build:
|
|
|
|
name: Build
|
2021-09-30 23:09:12 +09:00
|
|
|
runs-on: ubuntu-latest
|
2024-02-16 14:20:17 +09:00
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
platform:
|
|
|
|
- linux/amd64
|
|
|
|
- linux/arm64
|
2023-05-14 17:49:32 +09:00
|
|
|
if: github.repository == 'kokonect-link/cherrypick'
|
2021-09-30 23:09:12 +09:00
|
|
|
steps:
|
2023-10-18 18:55:43 +09:00
|
|
|
- name: Free Disk Space
|
2023-10-18 17:20:05 +09:00
|
|
|
uses: jlumbroso/free-disk-space@main
|
|
|
|
with:
|
|
|
|
# This might remove tools that are actually needed, if set to "true" but frees about 6 GB
|
|
|
|
tool-cache: false
|
|
|
|
# All of these default to true, but feel free to set to "false" if necessary for your workflow
|
|
|
|
android: true
|
|
|
|
dotnet: true
|
|
|
|
haskell: true
|
|
|
|
large-packages: true
|
|
|
|
swap-storage: true
|
2024-02-16 14:20:17 +09:00
|
|
|
- name: Prepare
|
|
|
|
run: |
|
|
|
|
platform=${{ matrix.platform }}
|
|
|
|
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
2021-09-30 23:09:12 +09:00
|
|
|
- name: Check out the repo
|
2023-10-19 19:35:13 +09:00
|
|
|
uses: actions/checkout@v4.1.1
|
2023-02-05 14:03:26 +09:00
|
|
|
- name: Set up Docker Buildx
|
2024-02-16 14:20:17 +09:00
|
|
|
uses: docker/setup-buildx-action@v3
|
2021-09-30 23:09:12 +09:00
|
|
|
- name: Log in to Docker Hub
|
2023-09-13 16:08:10 +09:00
|
|
|
uses: docker/login-action@v3
|
2021-09-30 23:09:12 +09:00
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
2024-02-16 14:20:17 +09:00
|
|
|
- name: Build and push by digest
|
|
|
|
id: build
|
2023-09-13 16:08:00 +09:00
|
|
|
uses: docker/build-push-action@v5
|
2021-09-30 23:09:12 +09:00
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
push: true
|
2024-02-16 14:20:17 +09:00
|
|
|
platforms: ${{ matrix.platform }}
|
2023-02-14 09:59:50 +09:00
|
|
|
provenance: false
|
2021-09-30 23:09:12 +09:00
|
|
|
labels: develop
|
2023-01-27 11:30:22 +09:00
|
|
|
cache-from: type=gha
|
|
|
|
cache-to: type=gha,mode=max
|
2024-02-16 14:20:17 +09:00
|
|
|
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
|
|
|
|
- name: Export digest
|
|
|
|
run: |
|
|
|
|
mkdir -p /tmp/digests
|
|
|
|
digest="${{ steps.build.outputs.digest }}"
|
|
|
|
touch "/tmp/digests/${digest#sha256:}"
|
|
|
|
- name: Upload digest
|
|
|
|
uses: actions/upload-artifact@v4
|
|
|
|
with:
|
|
|
|
name: digests-${{ env.PLATFORM_PAIR }}
|
|
|
|
path: /tmp/digests/*
|
|
|
|
if-no-files-found: error
|
|
|
|
retention-days: 1
|
|
|
|
|
|
|
|
merge:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs:
|
|
|
|
- build
|
|
|
|
steps:
|
|
|
|
- name: Download digests
|
|
|
|
uses: actions/download-artifact@v4
|
|
|
|
with:
|
|
|
|
path: /tmp/digests
|
|
|
|
pattern: digests-*
|
|
|
|
merge-multiple: true
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Docker Hub
|
|
|
|
uses: docker/login-action@v3
|
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: Create manifest list and push
|
|
|
|
working-directory: /tmp/digests
|
|
|
|
run: |
|
|
|
|
docker buildx imagetools create --tag ${{ env.REGISTRY_IMAGE }}:develop \
|
|
|
|
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
|
|
|
|
- name: Inspect image
|
|
|
|
run: |
|
|
|
|
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:develop
|