Skip to content

Commit 0d354cb

Browse files
authored
Merge pull request #17 from linuxfoundation/bramwelt/publish-container-branch
[LFXV2-306] GitHub workflow to build containers for branches
2 parents 32fb33f + 38b440e commit 0d354cb

File tree

3 files changed

+61
-9
lines changed

3 files changed

+61
-9
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Copyright The Linux Foundation and each contributor to LFX.
2+
# SPDX-License-Identifier: MIT
3+
---
4+
name: Publish Container Branch
5+
6+
"on":
7+
pull_request:
8+
branches:
9+
- main
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
publish:
16+
name: Publish Container
17+
if: ${{ github.event.pull_request.head.repo.fork == false }}
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: read
21+
packages: write
22+
steps:
23+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
24+
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5
25+
with:
26+
go-version-file: go.mod
27+
- uses: ko-build/setup-ko@d006021bd0c28d1ce33a07e7943d48b079944c8d # v0.9
28+
with:
29+
version: v0.18.0
30+
- name: Prepare container tag
31+
id: container_tag
32+
env:
33+
HEAD_REF: "${{ github.head_ref }}"
34+
run: |
35+
container_tag=$(echo "$HEAD_REF" | sed 's/[^_0-9a-zA-Z]/-/g' | cut -c -127)
36+
echo tag="$container_tag" >> "$GITHUB_OUTPUT"
37+
- name: Build project-api for PR
38+
run: |
39+
ko build github.com/linuxfoundation/lfx-v2-project-service/cmd/project-api \
40+
-B \
41+
--platform linux/amd64,linux/arm64 \
42+
-t ${{ github.sha }} \
43+
-t ${{ steps.container_tag.outputs.tag }} \
44+
--sbom spdx
45+
- name: Build root-project-setup for PR
46+
run: |
47+
ko build github.com/linuxfoundation/lfx-v2-project-service/scripts/root-project-setup \
48+
-B \
49+
--platform linux/amd64,linux/arm64 \
50+
-t ${{ github.sha }} \
51+
-t ${{ steps.container_tag.outputs.tag }} \
52+
--sbom spdx

.github/workflows/ko-build-main.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ jobs:
2020
contents: read
2121
packages: write
2222
steps:
23-
- uses: actions/checkout@v4
24-
- uses: actions/setup-go@v5
23+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
24+
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5
2525
with:
2626
go-version-file: go.mod
27-
- uses: ko-build/setup-ko@v0.8
27+
- uses: ko-build/setup-ko@d006021bd0c28d1ce33a07e7943d48b079944c8d # v0.9
2828
with:
29-
version: v0.17.1
29+
version: v0.18.0
3030
- run: |
3131
ko build github.com/linuxfoundation/lfx-v2-project-service/cmd/project-api \
3232
-B \

.github/workflows/ko-build-tag.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
chart_version: ${{ steps.prepare.outputs.chart_version }}
2929
steps:
3030
- name: Checkout repository
31-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
31+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
3232

3333
- name: Prepare versions and chart name
3434
id: prepare
@@ -44,14 +44,14 @@ jobs:
4444
} >> "$GITHUB_OUTPUT"
4545
4646
- name: Setup Go
47-
uses: actions/setup-go@v5
47+
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5
4848
with:
4949
go-version-file: go.mod
5050

5151
- name: Setup Ko
52-
uses: ko-build/setup-ko@v0.8
52+
uses: ko-build/setup-ko@d006021bd0c28d1ce33a07e7943d48b079944c8d # v0.9
5353
with:
54-
version: v0.17.1
54+
version: v0.18.0
5555

5656
- name: Build and publish project-api image
5757
run: |
@@ -85,7 +85,7 @@ jobs:
8585
image_name: ${{ steps.publish-ghcr.outputs.image_name }}
8686
steps:
8787
- name: Checkout repository
88-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
88+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
8989

9090
- name: Publish Chart to GHCR
9191
id: publish-ghcr

0 commit comments

Comments
 (0)