Skip to content

Commit 2ebe004

Browse files
Build a docker image in the publish workflow
1 parent 3d57170 commit 2ebe004

File tree

2 files changed

+53
-3
lines changed

2 files changed

+53
-3
lines changed

.github/workflows/publish.yml

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,18 @@ name: Publish
55
on:
66
push:
77
tags:
8-
- "v*"
8+
- 'v[0-9]*.[0-9]*.[0-9]*' # Matches semver tags in the format of v1.2.3
9+
- 'v[0-9]*.[0-9]*.[0-9]*-*' # Matches semver tags in the format of v1.2.3-beta
10+
11+
env:
12+
IMAGE_NAME: ghcr.io/usherlabs/cex-broker
913

1014
permissions:
1115
contents: read
1216
id-token: write
1317

1418
jobs:
15-
publish:
19+
publish-npm:
1620
runs-on: ubuntu-latest
1721

1822
steps:
@@ -50,4 +54,39 @@ jobs:
5054
run: bun run build
5155

5256
- name: Publish to npm
53-
run: npm publish --provenance --access public
57+
run: npm publish --provenance --access public
58+
59+
publish-docker:
60+
runs-on: ubuntu-latest
61+
needs: publish-npm
62+
steps:
63+
- name: Checkout repo
64+
uses: actions/checkout@v4
65+
66+
- name: Set up Docker Buildx
67+
uses: docker/setup-buildx-action@v3
68+
69+
- name: Log in to GitHub Container Registry
70+
uses: docker/login-action@v3
71+
with:
72+
registry: ghcr.io
73+
username: ${{ github.actor }}
74+
password: ${{ secrets.GITHUB_TOKEN }}
75+
76+
- name: Extract metadata
77+
id: meta
78+
uses: docker/metadata-action@v5
79+
with:
80+
images: ${{ env.IMAGE_NAME }}
81+
tags: |
82+
type=match,pattern=v(\d+\.\d+\.\d+.*),group=1
83+
84+
- name: Build and push Docker image
85+
uses: docker/build-push-action@v6
86+
with:
87+
context: .
88+
file: Dockerfile
89+
push: true
90+
tags: |
91+
${{ env.IMAGE_NAME }}:${{ fromJSON(steps.meta.outputs.json).tag-names[0] }}
92+
${{ env.IMAGE_NAME }}:latest

Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM oven/bun:1.3
2+
3+
WORKDIR /app
4+
5+
RUN apt-get update -y \
6+
&& apt-get install -y --no-install-recommends ca-certificates curl \
7+
&& rm -rf /var/lib/apt/lists/*
8+
9+
RUN bun install --global @usherlabs/cex-broker@0.2.5
10+
11+
CMD ["cex-broker"]

0 commit comments

Comments
 (0)