Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
151 changes: 151 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
name: M3tering Console Test and Publish Docker Image

on:
workflow_dispatch:
push:
pull_request:
branches:
- main

env:
REGISTRY: ghcr.io

permissions:
contents: read
packages: write
attestations: write
id-token: write

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "20"

- name: Install dependencies
run: npm install

- name: Run tests
run: npm test

build-platform:
needs: [test]
strategy:
matrix:
include:
- platform: linux/amd64
runner: ubuntu-latest
arch: amd64
- platform: linux/arm64
runner: ubuntu-24.04-arm
arch: arm64

runs-on: ${{ matrix.runner }}

steps:
- name: Checkout repository
uses: actions/checkout@v5

- name: Normalize image names
run: |
echo "CONSOLE_IMAGE_NAME=${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV

- name: Free disk space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Console image - push by digest with repository name
- name: Build Console image (single platform)
id: build-console
uses: docker/build-push-action@v6
with:
context: .
platforms: ${{ matrix.platform }}
push: ${{ github.event_name != 'pull_request' }}
outputs: type=image,name=${{ env.REGISTRY }}/${{ env.CONSOLE_IMAGE_NAME }},push-by-digest=true
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.CONSOLE_IMAGE_NAME }}:buildcache-${{ matrix.arch }}
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.CONSOLE_IMAGE_NAME }}:buildcache-${{ matrix.arch }},mode=max

- name: Save digests to files
if: github.event_name != 'pull_request'
run: |
echo ${{ steps.build-console.outputs.digest }} > digests-${{ matrix.arch }}-console-digest.txt

- name: Upload digests artifact
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@v4
with:
name: digests-${{ matrix.arch }}
path: |
digests-${{ matrix.arch }}-console-digest.txt

create-manifests:
needs: build-platform
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest

steps:
- name: Normalize image names
run: |
echo "CONSOLE_IMAGE_NAME=${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV

- name: Download all digests
uses: actions/download-artifact@v4
with:
pattern: digests-*
merge-multiple: true

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Extract metadata for Console image
id: meta-console
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.CONSOLE_IMAGE_NAME }}

- name: Create multi-arch manifest for Console
run: |
AMD64_DIGEST=$(cat digests-amd64-console-digest.txt)
ARM64_DIGEST=$(cat digests-arm64-console-digest.txt)
echo AMD64_DIGEST=$AMD64_DIGEST
echo ARM64_DIGEST=$ARM64_DIGEST
TAGS=(${{ steps.meta-console.outputs.tags }})
TAG_ARGS=""
for tag in "${TAGS[@]}"; do
TAG_ARGS="$TAG_ARGS --tag $tag"
done
docker buildx imagetools create $TAG_ARGS \
${{ env.REGISTRY }}/${{ env.CONSOLE_IMAGE_NAME }}@$AMD64_DIGEST \
${{ env.REGISTRY }}/${{ env.CONSOLE_IMAGE_NAME }}@$ARM64_DIGEST
21 changes: 0 additions & 21 deletions .github/workflows/test.yml

This file was deleted.

1 change: 1 addition & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
services:
console:
image: ghcr.io/m3tering/console:main
build: .
network_mode: host
restart: unless-stopped
Expand Down
Loading