Skip to content

Commit

Permalink
chore(actions): make builds multiplatform
Browse files Browse the repository at this point in the history
  • Loading branch information
Satont committed Jul 28, 2023
1 parent e76e1bd commit ec0b146
Showing 1 changed file with 52 additions and 5 deletions.
57 changes: 52 additions & 5 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Build and push docker images

on:
push:
branches:
- main
# branches:
# - main
workflow_dispatch:

jobs:
Expand All @@ -15,7 +15,6 @@ jobs:
[
api,
bots,
# dota,
eval,
eventsub,
integrations,
Expand All @@ -30,16 +29,18 @@ jobs:
ytsr,
migrations,
]
platform: [linux/arm64, linux/amd64]
steps:
- uses: actions/checkout@v3

- name: Prepare
id: prep
run: |
TAG=$(echo $GITHUB_SHA | head -c7)
IMAGE=${{ secrets.DOCKER_REGISTRY }}/twir/${{ matrix.application }}
IMAGE=${{ secrets.DOCKER_REGISTRY }}/twir/${{ matrix.application }}-${{ matrix.platform }}
echo ::set-output name=tagged_image::${IMAGE}:${TAG}
echo ::set-output name=tag::${TAG}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV

- name: Set up Docker Buildx
id: buildx
Expand Down Expand Up @@ -67,12 +68,58 @@ jobs:
with:
builder: ${{ steps.buildx.outputs.name }}
cache-from: type=local,src=/tmp/.buildx-cache
platforms: ${{ matrix.platform }}
context: .
push: true
file: ./Dockerfile
target: ${{ matrix.application }}
tags: |
${{ secrets.DOCKER_REGISTRY }}/twir/${{ matrix.application }}:latest
${{ secrets.DOCKER_REGISTRY }}/twir/${{ matrix.application }}:latest-${{ env.PLATFORM_PAIR }}

create-manifests:
runs-on: [self-hosted]
needs: [backend]
strategy:
matrix:
application:
[
api,
bots,
eval,
eventsub,
integrations,
parser,
scheduler,
timers,
watched,
websockets,
tokens,
emotes-cacher,
events,
ytsr,
migrations,
]

steps:
- uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Login to Container Registry
uses: docker/login-action@v1.14.1
with:
registry: ${{ secrets.DOCKER_REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Create latest manifest and push
run: |
docker manifest create \
${{ secrets.DOCKER_REGISTRY }}/twir/${{ matrix.application }}:latest \
--amend ${{ secrets.DOCKER_REGISTRY }}/twir/${{ matrix.application }}:latest-amd64 \
--amend ${{ secrets.DOCKER_REGISTRY }}/twir/${{ matrix.application }}:latest-arm64
docker manifest push ${{ secrets.DOCKER_REGISTRY }}/twir/${{ matrix.application }}:latest

frontend:
runs-on: ubuntu-latest
Expand Down

0 comments on commit ec0b146

Please sign in to comment.