Skip to content

Commit 96893ea

Browse files
committed
ci: GitHub Actions to build/test and publish Docker images to GHCR
Two workflows mirroring coinshift-rs's CI, adapted to simplepool: - check_build.yaml: compile the C11 stratum proxy and run 'make test' (installs the same -dev deps as the Docker build stage). - build_docker.yaml: build the three service images (simplepool, simplepool-dashboard, simplepool-payout) via a matrix and push them to ghcr.io/<owner>/<image> using the built-in GITHUB_TOKEN. PRs build-only. Both jobs are guarded with 'if: github.repository_owner == LayerTwo-Labs' so they run only in the canonical org repo (publishing to ghcr.io/layertwo-labs/*) and stay inert on a personal fork.
1 parent dc0cd9c commit 96893ea

2 files changed

Lines changed: 124 additions & 0 deletions

File tree

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Build the three simplepool container images and push them to the GitHub
2+
# Container Registry (ghcr.io) — the same registry coinshift-rs publishes to.
3+
#
4+
# This job runs only in the canonical LayerTwo-Labs repo (see the `if:` guard
5+
# on the job), so images land in the org namespace, tagged automatically:
6+
# ghcr.io/layertwo-labs/simplepool (C stratum proxy)
7+
# ghcr.io/layertwo-labs/simplepool-dashboard (Node read-only web UI)
8+
# ghcr.io/layertwo-labs/simplepool-payout (Node Thunder payout worker)
9+
#
10+
# Auth uses the built-in GITHUB_TOKEN — no secrets to configure, because the
11+
# repo lives in the same org that owns the packages (exactly like coinshift).
12+
# Pull-request runs build the images (to prove the Dockerfiles still work) but
13+
# do not push; only pushes to main, tags, and manual runs publish.
14+
name: Build and push Docker images
15+
16+
on:
17+
push:
18+
branches:
19+
- main
20+
tags:
21+
- "v*"
22+
workflow_dispatch:
23+
pull_request:
24+
25+
jobs:
26+
build-push-docker:
27+
runs-on: ubuntu-latest
28+
# Publish only from the LayerTwo-Labs org repo. On a personal fork/repo
29+
# (e.g. rsantacroce/simplepool) this is false, so the whole job is skipped
30+
# — nothing is built and nothing is pushed. (String compare is
31+
# case-insensitive, so 'LayerTwo-Labs' also matches 'layertwo-labs'.)
32+
if: github.repository_owner == 'LayerTwo-Labs'
33+
permissions:
34+
contents: read
35+
packages: write
36+
attestations: write
37+
id-token: write
38+
strategy:
39+
fail-fast: false
40+
matrix:
41+
include:
42+
- image: simplepool
43+
dockerfile: deploy/docker/Dockerfile.simplepool
44+
- image: simplepool-dashboard
45+
dockerfile: deploy/docker/Dockerfile.dashboard
46+
- image: simplepool-payout
47+
dockerfile: deploy/docker/Dockerfile.payout
48+
steps:
49+
- name: Checkout
50+
uses: actions/checkout@v4
51+
52+
- name: Docker meta
53+
id: meta
54+
uses: docker/metadata-action@v5
55+
with:
56+
images: |
57+
ghcr.io/${{ github.repository_owner }}/${{ matrix.image }}
58+
tags: |
59+
type=sha,event=push
60+
type=ref,event=pr
61+
type=ref,event=tag
62+
type=semver,pattern={{version}}
63+
type=raw,value=latest,enable={{is_default_branch}}
64+
65+
- name: Set up Docker Buildx
66+
uses: docker/setup-buildx-action@v3
67+
68+
- name: Login to GHCR
69+
# Skipped on pull_request, where we build-only and don't push.
70+
if: github.event_name != 'pull_request'
71+
uses: docker/login-action@v3
72+
with:
73+
registry: ghcr.io
74+
username: ${{ github.repository_owner }}
75+
password: ${{ secrets.GITHUB_TOKEN }}
76+
77+
- name: Build and push
78+
uses: docker/build-push-action@v6
79+
with:
80+
context: .
81+
file: ${{ matrix.dockerfile }}
82+
push: ${{ github.event_name != 'pull_request' }}
83+
tags: ${{ steps.meta.outputs.tags }}
84+
labels: ${{ steps.meta.outputs.labels }}
85+
# Per-image GitHub Actions cache so the three legs don't collide.
86+
cache-from: type=gha,scope=${{ matrix.image }}
87+
cache-to: type=gha,mode=max,scope=${{ matrix.image }}

.github/workflows/check_build.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Compile simplepool and run its unit tests on every push/PR.
2+
# simplepool is pure C11 (see Makefile); its deps are the same -dev packages
3+
# the build stage of deploy/docker/Dockerfile.simplepool installs.
4+
name: Build and test
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
pull_request:
11+
workflow_dispatch:
12+
13+
jobs:
14+
build-test:
15+
runs-on: ubuntu-latest
16+
# Match build_docker.yaml: CI runs only in the LayerTwo-Labs org repo, so
17+
# pushing to a personal repo doesn't spend Actions minutes. Remove this line
18+
# if you *do* want build/test CI to run on your own fork too.
19+
if: github.repository_owner == 'LayerTwo-Labs'
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Install build dependencies
25+
run: |
26+
sudo apt-get update
27+
sudo apt-get install -y --no-install-recommends \
28+
build-essential \
29+
libsqlite3-dev \
30+
libcurl4-openssl-dev \
31+
libhiredis-dev
32+
33+
- name: Build
34+
run: make -j"$(nproc)"
35+
36+
- name: Test
37+
run: make test

0 commit comments

Comments
 (0)