File tree 6 files changed +189
-12
lines changed
6 files changed +189
-12
lines changed Original file line number Diff line number Diff line change
1
+ name : Custom Image
2
+
3
+ on :
4
+ workflow_dispatch :
5
+ inputs : {}
6
+
7
+ permissions :
8
+ contents : write
9
+ packages : write
10
+ id-token : write
11
+
12
+ env :
13
+ REGISTRY : ghcr.io/sap
14
+ IMAGE_NAME : dev-${{ github.event.repository.name }}
15
+
16
+ jobs :
17
+ custom-image :
18
+ runs-on : ubuntu-latest
19
+ steps :
20
+ - name : Checkout repository
21
+ uses : actions/checkout@v3
22
+
23
+ - name : Get short sha
24
+ id : vars
25
+ run : echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
26
+
27
+ - name : Setup Go
28
+ uses : actions/setup-go@v4
29
+ with :
30
+ go-version-file : go.mod
31
+
32
+ - name : Log into registry ${{ env.REGISTRY }}
33
+ uses : docker/login-action@v2
34
+ with :
35
+ registry : ${{ env.REGISTRY }}
36
+ username : ${{ github.actor }}
37
+ password : ${{ secrets.GITHUB_TOKEN }}
38
+
39
+ - name : Build image
40
+ env :
41
+ IMAGE_NAME : ${{ env.IMAGE_NAME }}
42
+ VERSION : sha-${{ steps.vars.outputs.sha_short }}
43
+ run : |
44
+ env
45
+ make IMAGE_NAME="$IMAGE_NAME" VERSION="$VERSION" image
46
+
47
+ - name : Push image
48
+ env :
49
+ IMAGE : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:sha-${{ steps.vars.outputs.sha_short }}
50
+ run : docker push "$IMAGE"
Original file line number Diff line number Diff line change
1
+ name : Release
2
+
3
+ on :
4
+ push :
5
+ tags :
6
+ - ' v*'
7
+
8
+ permissions :
9
+ contents : write
10
+ packages : write
11
+ id-token : write
12
+
13
+ env :
14
+ REGISTRY : ghcr.io
15
+
16
+ jobs :
17
+ release :
18
+ runs-on : ubuntu-latest
19
+ steps :
20
+ - name : Checkout repository
21
+ uses : actions/checkout@v3
22
+ with :
23
+ fetch-depth : 0
24
+
25
+ - name : Fetch tags
26
+ run : git fetch --force --tags
27
+
28
+ - name : Setup Go
29
+ uses : actions/setup-go@v4
30
+ with :
31
+ go-version-file : go.mod
32
+
33
+ - name : Setup Docker buildx
34
+ uses : docker/setup-buildx-action@v2
35
+
36
+ - name : Log into registry ${{ env.REGISTRY }}
37
+ uses : docker/login-action@v2
38
+ with :
39
+ registry : ${{ env.REGISTRY }}
40
+ username : ${{ github.actor }}
41
+ password : ${{ secrets.GITHUB_TOKEN }}
42
+
43
+ - name : Invoke goreleaser
44
+ uses : goreleaser/goreleaser-action@v4
45
+ with :
46
+ distribution : goreleaser
47
+ version : latest
48
+ args : release --clean
49
+ env :
50
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
Original file line number Diff line number Diff line change
1
+ name : Go Tests
2
+
3
+ on :
4
+ pull_request :
5
+ branches :
6
+ - " main"
7
+ - " rel-*"
8
+
9
+ jobs :
10
+ test :
11
+ runs-on : ubuntu-latest
12
+ steps :
13
+ - name : Checkout repository
14
+ uses : actions/checkout@v3
15
+
16
+ - name : Setup Go
17
+ uses : actions/setup-go@v4
18
+ with :
19
+ go-version-file : go.mod
20
+
21
+ - name : Build
22
+ run : make build
23
+
24
+ - name : Tests
25
+ run : make test
Original file line number Diff line number Diff line change
1
+ project_name : remote-work-processor
2
+ builds :
3
+ - goos :
4
+ - linux
5
+ - darwin
6
+ - windows
7
+ goarch :
8
+ - amd64
9
+ - arm64
10
+ main : ./cmd/remote-work-processor/main.go
11
+ binary : remote-work-processor
12
+ ldflags : -s -w -X main.Version={{.Version}} -X main.BuildDate={{.Date}}
13
+ env :
14
+ - CGO_ENABLED=0
15
+ dockers :
16
+ - dockerfile : Dockerfile
17
+ image_templates :
18
+ - " ghcr.io/sap/{{ .ProjectName }}:{{ .Version }}"
19
+ - " ghcr.io/sap/{{ .ProjectName }}:{{ .Major }}.{{ .Minor }}"
20
+ use : buildx
21
+ goos : linux
22
+ goarch : amd64
23
+ build_flag_templates :
24
+ - --platform=linux/amd64
25
+ - --label=org.opencontainers.image.created={{ .Date }}
26
+ - --label=org.opencontainers.image.title={{ .ProjectName }}
27
+ - --label=org.opencontainers.image.version={{ .Version }}
28
+ - --label=org.opencontainers.image.revision={{ .FullCommit }}
29
+ - --label=org.opencontainers.image.description={{ .ProjectName }} {{ .Version }}
30
+ - --label=org.opencontainers.image.source=https://github.com/sap/{{ .ProjectName }}
31
+ archives :
32
+ - format : binary
33
+ name_template : " {{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
34
+ checksum :
35
+ name_template : ' checksums.txt'
36
+ changelog :
37
+ sort : asc
38
+ use : git
39
+ release :
40
+ footer : |
41
+ ## Docker Images
42
+
43
+ - `docker pull ghcr.io/sap/{{.ProjectName}}:{{ .Version }}`
Original file line number Diff line number Diff line change 1
- FROM golang:1.20-bullseye as builder
2
-
3
- WORKDIR /autopi
4
-
5
- # Copy the Go Modules manifests
6
- COPY . .
7
-
8
- # Build
9
- RUN CGO_ENABLED=0 make build
10
-
11
1
# Use distroless as minimal base image to package the manager binary
12
2
# Refer to https://github.com/GoogleContainerTools/distroless for more details
13
3
FROM gcr.io/distroless/static-debian11:nonroot
14
4
5
+ ARG BIN_FILE=./remote-work-processor
6
+
15
7
WORKDIR /
16
- COPY --from=builder /autopi/remote-work-processor .
8
+ COPY ${BIN_FILE} .
17
9
18
10
USER 65532:65532
19
11
Original file line number Diff line number Diff line change 1
1
# !/usr/bin/make -f
2
2
3
- OUT_EXEC ?= dist/remote-work-processor
3
+ OUT_DIR ?= dist
4
+ OUT_NAME ?= remote-work-processor
5
+ OUT_EXEC = $(OUT_DIR ) /$(OUT_NAME )
4
6
MAIN = ./cmd/remote-work-processor/main.go
5
7
PROTO_DIR = build/proto
8
+ DOCKER ?= docker
9
+ REGISTRY ?= ghcr.io/sap
10
+ IMAGE_NAME ?= remote-work-processor
11
+ VERSION ?= dev
12
+ IMAGE_TAG = $(REGISTRY ) /$(IMAGE_NAME ) :$(VERSION )
6
13
7
14
build : fmt vet
8
15
$(CURDIR ) /scripts/build.sh " $( MAIN) " $(OUT_EXEC )
9
16
17
+ image : build
18
+ $(DOCKER ) build \
19
+ --no-cache \
20
+ --tag $(IMAGE_TAG ) \
21
+ --build-arg BIN_FILE=$(OUT_EXEC ) \
22
+ .
23
+
24
+ test :
25
+ go test ./...
26
+
10
27
fmt :
11
28
$(CURDIR ) /scripts/assertgofmt.sh
12
29
You can’t perform that action at this time.
0 commit comments