mashirozx/mastodon

View on GitHub
.github/workflows/docker-build-release.yml

Summary

Maintainability
Test Coverage
name: Build Image for Release

on:
  release:
    types: [published]

jobs:
  docker-build:
    runs-on: ubuntu-latest
    if: ${{ !contains(github.event.commits.*.message, '[skip ci]') && !contains(github.event.commits.*.message, '[ci skip]') }}

    strategy:
      matrix:
        platform: [amd64, arm64, universal]

    steps:
      - name: 🔍 Checkout code
        uses: actions/checkout@v2

      - name: 🦄 Set up Qemu for Docker
        uses: docker/setup-qemu-action@v1

      - name: 🏗️ Set up Docker Buildx
        uses: docker/setup-buildx-action@v1

      - name: 🔑 Login to DockerHub
        uses: docker/login-action@v1
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}

      - name: ⚓ Build and push arm64 image
        uses: docker/build-push-action@v2
        with:
          context: .
          pull: true
          push: true
          platforms: linux/${{ matrix.platform }}
          cache-from: type=registry,ref=mashirozx/mastodon:${{ github.event.release.tag_name }}-${{ matrix.platform }}
          cache-to: type=inline
          tags:  mashirozx/mastodon:${{ github.event.release.tag_name }}-${{ matrix.platform }}
        if: ${{ matrix.platform == 'arm64' }}

      - name: ⚓ Build and push amd64 image
        uses: docker/build-push-action@v2
        with:
          context: .
          pull: true
          push: true
          platforms: linux/${{ matrix.platform }}
          cache-from: type=registry,ref=mashirozx/mastodon:${{ github.event.release.tag_name }}-${{ matrix.platform }}
          cache-to: type=inline
          tags: |
            mashirozx/mastodon:${{ github.event.release.tag_name }}-${{ matrix.platform }}
        if: ${{ matrix.platform == 'amd64' }}
        
      - name: ⚓ Build and push universal image
        uses: docker/build-push-action@v2
        with:
          context: .
          pull: true
          push: true
          platforms: linux/amd64, linux/arm64
          cache-from: type=registry,ref=mashirozx/mastodon:${{ github.event.release.tag_name }}
          cache-to: type=inline
          tags: |
            mashirozx/mastodon:${{ github.event.release.tag_name }}
        if: ${{ matrix.platform == 'universal' }}