-
Notifications
You must be signed in to change notification settings - Fork 9
100 lines (92 loc) · 3.55 KB
/
build-hub.yaml
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Build Hub
on:
push:
branches:
- 'main'
tags:
- '*'
pull_request:
jobs:
build:
name: Build
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Go
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
with:
go-version-file: 'go.mod'
check-latest: true
cache-dependency-path: |
go.sum
- name: Setup node.js
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
with:
node-version: '22'
cache: npm
registry-url: 'https://registry.npmjs.org'
- name: Generate commit hash
id: hash
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Install frontend dependencies with npm
run: npm ci
- name: Lint with prettier
run: npm run lint
- name: Lint with golangci-lint
uses: golangci/golangci-lint-action@818ec4d51a1feacefc42ff1b3ec25d4962690f39 # v6.4.1
with:
version: latest
- name: Build frontend
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
run: npm run build:prod
- name: Build frontend and upload source maps (tag only)
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: |
npm run build:prod -- --source-map=true || exit 1
npm run sentry-upload || exit 1
rm internal/frontend/dist/ui/browser/*.map || exit 1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
VERSION: ${{ github.ref_name }}
- name: Build application
run: go build -ldflags="$LDFLAGS" -o dist/distr ./cmd/hub/
env:
CGO_ENABLED: '0'
LDFLAGS: >-
-X github.com/glasskube/distr/internal/buildconfig.version=${{ github.ref_name }}
-X github.com/glasskube/distr/internal/buildconfig.commit=${{ steps.hash.outputs.sha_short }}
- name: Login to GitHub Container Registry (tag only)
if: ${{ startsWith(github.ref, 'refs/tags/') }}
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f7ce87c1d6bead3e36075b2ce75da1f6cc28aaca # v3.9.0
- name: Generate Docker Metadata
id: meta
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5.6.1
with:
images: ghcr.io/glasskube/distr
tags: |
type=ref,event=branch
type=sha,event=branch
type=semver,pattern={{version}}
labels: |
org.opencontainers.image.description=Distr Hub
org.opencontainers.image.vendor=Glasskube
- name: Docker build (push on tag only)
uses: docker/build-push-action@ca877d9245402d1537745e0e356eab47c3520991 # v6.13.0
with:
platforms: ${{ startsWith(github.ref, 'refs/tags/') && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
context: .
file: Dockerfile.hub
push: ${{ startsWith(github.ref, 'refs/tags/') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max