-
Notifications
You must be signed in to change notification settings - Fork 54
121 lines (106 loc) · 3.96 KB
/
build-ccm-gcp.yml
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
name: Build and Upload GCP CCM container image
on:
push:
branches:
- 'main'
paths:
- '.github/workflows/build-ccm-gcp.yml'
- '.github/actions/gcpccm_vers_to_build/**'
schedule:
- cron: "0 4 * * 3" # Every Wednesday at 4am UTC
workflow_dispatch:
jobs:
find-ccm-versions:
runs-on: ubuntu-24.04
outputs:
versions: ${{ steps.find-versions.outputs.versions }}
latest: ${{ steps.find-latest.outputs.latest }}
steps:
- name: Checkout Constellation
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Checkout kubernetes/cloud-provider-gcp
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: "kubernetes/cloud-provider-gcp"
path: "cloud-provider-gcp"
fetch-depth: 0
- name: Setup Go environment
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version: "1.23.2"
cache: false
- name: Install Crane
run: |
go install github.com/google/go-containerregistry/cmd/crane@c195f151efe3369874c72662cd69ad43ee485128 # v0.20.2
- name: Find versions
id: find-versions
uses: ./.github/actions/gcpccm_vers_to_build
with:
path: "cloud-provider-gcp"
- name: Find latest
id: find-latest
run: |
rawList=$(jq -r '.[]' <<< '${{ steps.find-versions.outputs.versions }}')
lastest=$(echo "${rawList}" | sort -V | tail -n 1)
echo "latest=${lastest}" | tee -a "$GITHUB_OUTPUT"
build-ccm-gcp:
# matrix cannot handle empty lists
if: needs.find-ccm-versions.outputs.versions != '[]'
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
needs: find-ccm-versions
strategy:
fail-fast: false
matrix:
version: ${{ fromJson(needs.find-ccm-versions.outputs.versions) }}
steps:
- name: Checkout Constellation
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Checkout kubernetes/cloud-provider-gcp
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: "kubernetes/cloud-provider-gcp"
path: "cloud-provider-gcp"
ref: refs/tags/ccm/${{ matrix.version }}
- name: Docker meta
id: meta
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5.6.1
with:
images: |
ghcr.io/edgelesssys/cloud-provider-gcp
flavor: |
latest=${{ matrix.version == needs.find-ccm-versions.outputs.latest }}
tags: |
type=semver,pattern=v{{version}},value=${{ matrix.version }}
- name: Log in to the Container registry
id: docker-login
uses: ./.github/actions/container_registry_login
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build CCM
working-directory: cloud-provider-gcp
run: |
bazel build //cmd/cloud-controller-manager:cloud-controller-manager
- name: Copy CCM
working-directory: cloud-provider-gcp
run: |
cp ./bazel-bin/cmd/cloud-controller-manager/cloud-controller-manager_/cloud-controller-manager ./cloud-controller-manager
- name: Prepare Dockerfile
working-directory: cloud-provider-gcp
run: |
cat > Dockerfile <<EOF
FROM scratch
COPY ./cloud-controller-manager /cloud-controller-manager
EOF
- name: Build and push container image
id: build
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6.10.0
with:
context: ./cloud-provider-gcp
push: ${{ github.ref_name == 'main' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}