-
Notifications
You must be signed in to change notification settings - Fork 93
53 lines (44 loc) · 1.28 KB
/
container.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
name: Create and publish a Docker image to ghcr on main and nightly with ko
on:
push:
paths:
- "**.go"
- "**.yaml"
pull_request:
paths:
- "**.go"
- "**.yaml"
env:
PLATFORMS: linux/amd64,linux/arm64,linux/ppc64le
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
- uses: ko-build/[email protected]
- name: Build and push images
shell: bash
run: |
set -x
releaseBranchFormat='release-v'
if [[ ${{ github.ref_name }} == ${releaseBranchFormat}* ]]; then
tag="${${{ github.ref_name }}#*-}"
elif [[ ${{ github.ref }} == refs/pull/* ]]; then
tag=pr-$(echo ${{ github.ref }} | cut -c11-|sed 's,/merge,,')
else
tag=$(echo ${{ github.ref_name }}|sed 's,/merge,,')
fi
for image in ./cmd/*;do
ko build -B -t "${tag}" --platform="${{ env.PLATFORMS }}" "${image}"
done