-
Notifications
You must be signed in to change notification settings - Fork 74
54 lines (48 loc) · 1.36 KB
/
reusable-golang.yml
File metadata and controls
54 lines (48 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
name: Build & Push Golang Docker Image
on:
workflow_call:
inputs:
image_name:
required: true
type: string
tag:
required: true
type: string
flags:
required: false
type: string
jobs:
build:
name: Build
runs-on: ubuntu-24.04
steps:
- name: Check out code into the right branch
uses: actions/checkout@v4
- name: Set up Go 1.x
uses: actions/setup-go@v5
with:
go-version: ^1.20
id: go
- name: Running Tests
working-directory: ./${{inputs.image_name}}
run: go test -v ./...
- name: Build Binary
working-directory: ./${{inputs.image_name}}
run: |
if [ -n "${{inputs.flags}}" ]; then
go build -o ${{inputs.image_name}} -v -ldflags "${{inputs.flags}}" .
else
go build -o ${{inputs.image_name}} -v .
fi
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: utmstack
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push the Image
uses: docker/build-push-action@v6
with:
context: ./${{inputs.image_name}}
push: true
tags: ghcr.io/utmstack/utmstack/${{inputs.image_name}}:${{inputs.tag}}