|
| 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 }} |
0 commit comments