Skip to content

Commit b7b2247

Browse files
committed
Address #211
Fixed the image build and publishing step.
1 parent e262f48 commit b7b2247

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

.github/workflows/publish.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,13 @@ jobs:
126126
type=raw,value=${{ github.event.client_payload.new-tag }}
127127
type=raw,value=latest
128128
129+
- name: Capture Docker build metadata
130+
id: docker_build_meta
131+
run: |
132+
echo "version=${{ github.event.client_payload.new-tag }}" >> "$GITHUB_OUTPUT"
133+
echo "commit=${GITHUB_SHA}" >> "$GITHUB_OUTPUT"
134+
echo "date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$GITHUB_OUTPUT"
135+
129136
- name: Build and push Docker images
130137
uses: docker/build-push-action@v6
131138
with:
@@ -134,5 +141,9 @@ jobs:
134141
push: true
135142
tags: ${{ steps.meta.outputs.tags }}
136143
labels: ${{ steps.meta.outputs.labels }}
144+
build-args: |
145+
APP_VERSION=${{ steps.docker_build_meta.outputs.version }}
146+
APP_COMMIT=${{ steps.docker_build_meta.outputs.commit }}
147+
APP_DATE=${{ steps.docker_build_meta.outputs.date }}
137148
cache-from: type=gha
138149
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
FROM --platform=$BUILDPLATFORM node:22-bookworm-slim AS ui-builder
22

33
WORKDIR /opt/openapi-changes/html-report/ui
4-
COPY html-report/ui/package.json html-report/ui/package-lock.json ./
4+
COPY html-report/ui/package.json html-report/ui/package-lock.json html-report/ui/tsconfig.json html-report/ui/vite.config.ts html-report/ui/index.html ./
5+
COPY html-report/ui/src ./src
56
RUN npm ci
6-
COPY html-report/ui/ ./
77
RUN npm run build
88

99
FROM --platform=$BUILDPLATFORM golang:1.25-bookworm AS builder
@@ -12,6 +12,9 @@ ARG TARGETPLATFORM
1212
ARG BUILDPLATFORM
1313
ARG TARGETOS
1414
ARG TARGETARCH
15+
ARG APP_VERSION=dev
16+
ARG APP_COMMIT=unknown
17+
ARG APP_DATE=1970-01-01T00:00:00Z
1518

1619
RUN mkdir -p /opt/openapi-changes
1720

@@ -21,7 +24,9 @@ COPY . ./
2124
COPY --from=ui-builder /opt/openapi-changes/html-report/ui/build/ html-report/ui/build/
2225

2326
RUN go mod download && go mod verify
24-
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -ldflags="-w -s" -v -o /openapi-changes openapi-changes.go
27+
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build \
28+
-ldflags="-w -s -X main.version=${APP_VERSION} -X main.commit=${APP_COMMIT} -X main.date=${APP_DATE}" \
29+
-v -o /openapi-changes openapi-changes.go
2530

2631
FROM --platform=$TARGETPLATFORM debian:bookworm-slim
2732
RUN apt-get update && apt-get --yes install git && rm -rf /var/lib/apt/lists/*

0 commit comments

Comments
 (0)