-
Notifications
You must be signed in to change notification settings - Fork 10
64 lines (61 loc) · 2.21 KB
/
build-agent.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
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Build Agents
on:
push:
branches:
- 'main'
tags:
- '*'
pull_request:
jobs:
build-agent:
timeout-minutes: 20
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
agent:
- docker-agent
- kubernetes-agent
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Generate commit hash
id: generate
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Login to GitHub Container Registry
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/${{ matrix.agent }}
tags: |
type=ref,event=branch
type=sha,event=branch
type=semver,pattern={{version}}
labels: |
org.opencontainers.image.description=Distr agent software
org.opencontainers.image.vendor=Glasskube
- name: Docker build (push only for tag)
uses: docker/build-push-action@ca877d9245402d1537745e0e356eab47c3520991 # v6.13.0
with:
platforms: ${{ startsWith(github.ref, 'refs/tags/') && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
file: Dockerfile.${{ matrix.agent }}
build-args: |
COMMIT=${{ steps.generate.outputs.sha_short }}
VERSION=${{ github.ref_name }}
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