2021-09-09 12:28:02 +02:00
|
|
|
name: Publish Docker image
|
|
|
|
|
|
|
|
on:
|
|
|
|
release:
|
|
|
|
types: [published]
|
|
|
|
workflow_dispatch:
|
|
|
|
|
2024-02-16 06:20:17 +01:00
|
|
|
env:
|
|
|
|
REGISTRY_IMAGE: misskey/misskey
|
2024-02-16 07:58:54 +01:00
|
|
|
TAGS: |
|
|
|
|
type=edge
|
|
|
|
type=ref,event=pr
|
|
|
|
type=ref,event=branch
|
|
|
|
type=semver,pattern={{version}}
|
|
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
|
|
type=semver,pattern={{major}}
|
2024-02-16 06:20:17 +01:00
|
|
|
|
2021-09-09 12:28:02 +02:00
|
|
|
jobs:
|
2024-02-16 06:20:17 +01:00
|
|
|
# see https://docs.docker.com/build/ci/github-actions/multi-platform/#distribute-build-across-multiple-runners
|
|
|
|
build:
|
|
|
|
name: Build
|
2021-09-09 12:28:02 +02:00
|
|
|
runs-on: ubuntu-latest
|
2024-02-16 06:20:17 +01:00
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
platform:
|
|
|
|
- linux/amd64
|
|
|
|
- linux/arm64
|
2021-09-09 12:28:02 +02:00
|
|
|
steps:
|
2024-02-16 06:20:17 +01:00
|
|
|
- name: Prepare
|
|
|
|
run: |
|
|
|
|
platform=${{ matrix.platform }}
|
|
|
|
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
2021-09-09 12:28:02 +02:00
|
|
|
- name: Check out the repo
|
2023-10-19 12:35:13 +02:00
|
|
|
uses: actions/checkout@v4.1.1
|
2023-02-14 01:59:50 +01:00
|
|
|
- name: Set up Docker Buildx
|
2024-02-16 06:20:17 +01:00
|
|
|
uses: docker/setup-buildx-action@v3
|
2021-09-09 12:28:02 +02:00
|
|
|
- name: Docker meta
|
|
|
|
id: meta
|
2023-09-13 09:08:30 +02:00
|
|
|
uses: docker/metadata-action@v5
|
2021-09-09 12:28:02 +02:00
|
|
|
with:
|
2024-02-16 06:20:17 +01:00
|
|
|
images: ${{ env.REGISTRY_IMAGE }}
|
2024-02-16 07:58:54 +01:00
|
|
|
tags: ${{ env.TAGS }}
|
2021-09-09 12:28:02 +02:00
|
|
|
- name: Log in to Docker Hub
|
2023-09-13 09:08:10 +02:00
|
|
|
uses: docker/login-action@v3
|
2021-09-09 12:28:02 +02:00
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: Build and Push to Docker Hub
|
2024-02-16 06:20:17 +01:00
|
|
|
id: build
|
2024-06-22 05:45:52 +02:00
|
|
|
uses: docker/build-push-action@v6
|
2021-09-09 12:28:02 +02:00
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
push: true
|
2024-02-16 06:20:17 +01:00
|
|
|
platforms: ${{ matrix.platform }}
|
2023-02-14 01:59:50 +01:00
|
|
|
provenance: false
|
2021-09-09 12:28:02 +02:00
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|
2023-02-14 01:59:50 +01:00
|
|
|
cache-from: type=gha
|
|
|
|
cache-to: type=gha,mode=max
|
2024-02-16 06:20:17 +01: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: Docker meta
|
|
|
|
id: meta
|
|
|
|
uses: docker/metadata-action@v5
|
|
|
|
with:
|
|
|
|
images: ${{ env.REGISTRY_IMAGE }}
|
2024-02-16 07:58:54 +01:00
|
|
|
tags: ${{ env.TAGS }}
|
2024-02-16 06:20:17 +01:00
|
|
|
- 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 $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
|
|
|
|
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
|
|
|
|
- name: Inspect image
|
|
|
|
run: |
|
|
|
|
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
|