-
Notifications
You must be signed in to change notification settings - Fork 84
81 lines (71 loc) · 2.36 KB
/
runme-image.yml
File metadata and controls
81 lines (71 loc) · 2.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
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
name: Runme Image
on:
push:
branches:
- main
tags:
- 'v*'
pull_request:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ">=1.25"
- name: Set up ko
uses: ko-build/setup-ko@v0.6
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Download static app assets.
# This relies on assets.go embedding the contents of dist/* into the go binary
# The advantage of embedding directly in the go binary is that we can then make the binary serve the static
# assets without needing to manage the assets separately. This could be useful if we want to use the
# web app as an "admin" panel for bootstrapping the UI.
# For a docker container it might make sense to package the assets on the filesystem but then we'd have two
# different mechanisms for the docker image vs. standalone binary.
# Right now the static assets are only around 3.4Mb
- name: Pull app assets (OCI)
run: |
rm -rf ./kodata
go run . agent download-assets --assets-dir ./kodata
- name: Compute image tags
id: tags
shell: bash
run: |
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
tags="${GITHUB_REF_NAME}"
else
tags="sha-${GITHUB_SHA::7}"
if [[ "${GITHUB_REF_NAME}" == "main" ]]; then
tags="${tags},latest"
fi
fi
echo "tags=${tags}" >> "$GITHUB_OUTPUT"
- name: Build and publish image
if: github.event_name != 'pull_request'
env:
KO_DOCKER_REPO: ghcr.io/runmedev/runme
run: |
ko build ./ \
--bare \
--platform=linux/amd64,linux/arm64 \
--tags "${{ steps.tags.outputs.tags }}" \
--sbom=none
- name: Build image (PR)
if: github.event_name == 'pull_request'
run: |
ko build ./ --bare --local --sbom=none