Consolidate github actions to prevent duplication #79
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Master Server Build and Push | |
on: | |
push: | |
branches: | |
- master | |
paths: | |
- "server/**" | |
- "Cargo.toml" | |
- "Cargo.lock" | |
- ".github/workflows/server-push.yml" | |
jobs: | |
server-build-and-push: | |
strategy: | |
matrix: | |
include: | |
- runner: ubuntu-latest | |
platform: linux/amd64 | |
arch: amd64 | |
- runner: ubuntu-24.04-arm | |
platform: linux/arm64 | |
arch: arm64 | |
runs-on: ${{ matrix.runner }} | |
steps: | |
- name: π Checkout code | |
uses: actions/checkout@v4 | |
- name: π Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: π Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: π Build and push ${{ matrix.arch }} | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: ${{ matrix.platform }} | |
push: true | |
tags: ghcr.io/blixtwallet/noah-server:latest-${{ matrix.arch }} | |
cache-from: type=gha,scope=${{ matrix.arch }} | |
cache-to: type=gha,mode=max,scope=${{ matrix.arch }} | |
create-manifest: | |
needs: server-build-and-push | |
runs-on: ubuntu-latest | |
steps: | |
- name: π Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: π― Create and push multi-arch manifest | |
run: | | |
docker buildx imagetools create -t ghcr.io/blixtwallet/noah-server:latest \ | |
ghcr.io/blixtwallet/noah-server:latest-amd64 \ | |
ghcr.io/blixtwallet/noah-server:latest-arm64 |