Skip to content

Commit 47afbfa

Browse files
committed
build: add workflow that publish image to harbor
1 parent 3a9cf02 commit 47afbfa

3 files changed

Lines changed: 53 additions & 3 deletions

File tree

.github/workflows/push-image.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Build and push bpctl image
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
tags: [ "v*" ]
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
permissions:
13+
contents: read
14+
15+
steps:
16+
- name: Checkout source
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Docker Buildx
20+
uses: docker/setup-buildx-action@v3
21+
22+
- name: Log in to Harbor
23+
uses: docker/login-action@v3
24+
with:
25+
registry: harbor.nbis.se
26+
username: ${{ secrets.HARBOR_USERNAME }}
27+
password: ${{ secrets.HARBOR_PASSWORD }}
28+
29+
- name: Extract version
30+
id: version
31+
run: |
32+
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
33+
echo "version=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT"
34+
else
35+
echo "version=dev-${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"
36+
fi
37+
38+
- name: Build and push image
39+
uses: docker/build-push-action@v6
40+
with:
41+
context: .
42+
file: Containerfile
43+
push: true
44+
build-args: |
45+
VERSION=${{ steps.version.outputs.version }}
46+
tags: |
47+
harbor.nbis.se/myproject/bpctl:${{ steps.version.outputs.version }}
48+
harbor.nbis.se/myproject/bpctl:latest

Containerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# Buld stage
22
FROM golang:1.24 AS builder
3+
ARG VERSION=dev
34
WORKDIR /app
45
COPY go.mod go.sum ./
56
RUN go mod download
67
COPY . .
7-
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bpctl .
8+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
9+
go build -ldflags "-X main.version=${VERSION}" -o bpctl .
810

911
# Run stage
1012
FROM gcr.io/distroless/cc:nonroot

helpers/templates/job.template.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,14 @@ spec:
101101
volumeMounts:
102102
- name: data-volume
103103
mountPath: /data
104-
- name: xml-data
104+
- name: xml-data-{{ .JobName }}
105105
mountPath: /data/xml-data/
106106
- name: tls
107107
mountPath: /.secrets/tls/
108108
volumes:
109109
- name: data-volume
110110
emptyDir: {}
111-
- name: xml-data
111+
- name: xml-data-{{ .JobName }}
112112
secret:
113113
defaultMode: 288
114114
secretName: {{ .MailXmlSecretName }}

0 commit comments

Comments
 (0)