Skip to content

Commit

Permalink
ci(gh-actions): build image for releases
Browse files Browse the repository at this point in the history
  • Loading branch information
mashirozx committed Jul 11, 2022
1 parent f3d1ed2 commit 2d5055e
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/docker-build-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
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' }}

0 comments on commit 2d5055e

Please sign in to comment.