2022-08-03 05:46:11 -04:00
|
|
|
name: Build and Upload GCP CCM container image
|
2023-08-16 04:42:40 -04:00
|
|
|
|
|
|
|
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:
|
2022-08-03 05:46:11 -04:00
|
|
|
|
|
|
|
jobs:
|
2023-08-16 04:42:40 -04:00
|
|
|
find-ccm-versions:
|
|
|
|
runs-on: ubuntu-22.04
|
|
|
|
outputs:
|
|
|
|
versions: ${{ steps.find-versions.outputs.versions }}
|
|
|
|
latest: ${{ steps.find-latest.outputs.latest }}
|
|
|
|
steps:
|
|
|
|
- name: Checkout Constellation
|
|
|
|
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
|
|
|
|
|
|
|
- name: Checkout kubernetes/cloud-provider-gcp
|
|
|
|
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
|
|
|
with:
|
|
|
|
repository: "kubernetes/cloud-provider-gcp"
|
|
|
|
path: "cloud-provider-gcp"
|
|
|
|
fetch-depth: 0
|
|
|
|
|
|
|
|
- name: Setup Go environment
|
|
|
|
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
|
|
|
|
with:
|
2023-09-28 16:29:14 -04:00
|
|
|
go-version: "1.21.1"
|
2023-08-16 04:42:40 -04:00
|
|
|
cache: false
|
|
|
|
|
|
|
|
- name: Install Crane
|
|
|
|
run: |
|
|
|
|
go install github.com/google/go-containerregistry/cmd/crane@latest
|
|
|
|
|
|
|
|
- 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"
|
|
|
|
|
2022-08-03 05:46:11 -04:00
|
|
|
build-ccm-gcp:
|
2023-08-23 05:42:16 -04:00
|
|
|
# matrix cannot handle empty lists
|
|
|
|
if: needs.find-ccm-versions.outputs.versions != '[]'
|
2022-11-10 10:55:24 -05:00
|
|
|
runs-on: ubuntu-22.04
|
2022-08-03 05:46:11 -04:00
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
packages: write
|
2023-08-16 04:42:40 -04:00
|
|
|
needs: find-ccm-versions
|
2022-08-03 05:46:11 -04:00
|
|
|
strategy:
|
2023-08-16 04:42:40 -04:00
|
|
|
fail-fast: false
|
2022-08-03 05:46:11 -04:00
|
|
|
matrix:
|
2023-08-16 04:42:40 -04:00
|
|
|
version: ${{ fromJson(needs.find-ccm-versions.outputs.versions) }}
|
2022-08-03 05:46:11 -04:00
|
|
|
steps:
|
2023-08-16 04:42:40 -04:00
|
|
|
- name: Checkout Constellation
|
|
|
|
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
|
|
|
|
2023-01-18 04:15:58 -05:00
|
|
|
- name: Checkout kubernetes/cloud-provider-gcp
|
2023-07-03 02:19:10 -04:00
|
|
|
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
2022-08-03 05:46:11 -04:00
|
|
|
with:
|
2022-09-02 11:00:29 -04:00
|
|
|
repository: "kubernetes/cloud-provider-gcp"
|
2023-08-16 04:42:40 -04:00
|
|
|
path: "cloud-provider-gcp"
|
2022-08-03 05:46:11 -04:00
|
|
|
ref: refs/tags/ccm/${{ matrix.version }}
|
|
|
|
|
|
|
|
- name: Docker meta
|
|
|
|
id: meta
|
2023-07-03 02:19:10 -04:00
|
|
|
uses: docker/metadata-action@818d4b7b91585d195f67373fd9cb0332e31a7175 # v4.6.0
|
2022-08-03 05:46:11 -04:00
|
|
|
with:
|
|
|
|
images: |
|
2023-08-16 04:42:40 -04:00
|
|
|
ghcr.io/edgelesssys/cloud-provider-gcp
|
2022-08-03 05:46:11 -04:00
|
|
|
flavor: |
|
2023-08-16 04:42:40 -04:00
|
|
|
latest=${{ matrix.version == needs.find-ccm-versions.outputs.latest }}
|
2022-08-03 05:46:11 -04:00
|
|
|
tags: |
|
2022-09-02 11:00:29 -04:00
|
|
|
type=semver,pattern=v{{version}},value=${{ matrix.version }}
|
2022-09-14 09:14:26 -04:00
|
|
|
|
2022-08-03 05:46:11 -04:00
|
|
|
- name: Log in to the Container registry
|
|
|
|
id: docker-login
|
2023-06-06 06:20:09 -04:00
|
|
|
uses: ./.github/actions/container_registry_login
|
2022-08-03 05:46:11 -04:00
|
|
|
with:
|
2023-08-16 04:42:40 -04:00
|
|
|
registry: ghcr.io
|
2022-08-03 05:46:11 -04:00
|
|
|
username: ${{ github.actor }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
|
|
|
- name: Build CCM
|
2023-08-16 04:42:40 -04:00
|
|
|
working-directory: cloud-provider-gcp
|
2022-08-03 05:46:11 -04:00
|
|
|
run: |
|
2023-05-19 09:36:54 -04:00
|
|
|
bazel build //cmd/cloud-controller-manager:cloud-controller-manager
|
2023-01-18 04:15:58 -05:00
|
|
|
|
2022-08-03 05:46:11 -04:00
|
|
|
- name: Copy CCM
|
2023-08-16 04:42:40 -04:00
|
|
|
working-directory: cloud-provider-gcp
|
2022-08-03 05:46:11 -04:00
|
|
|
run: |
|
2023-08-16 04:42:40 -04:00
|
|
|
cp ./bazel-bin/cmd/cloud-controller-manager/cloud-controller-manager_/cloud-controller-manager ./cloud-controller-manager
|
2023-01-18 04:15:58 -05:00
|
|
|
|
2022-08-03 05:46:11 -04:00
|
|
|
- name: Prepare Dockerfile
|
2023-08-16 04:42:40 -04:00
|
|
|
working-directory: cloud-provider-gcp
|
2022-08-03 05:46:11 -04:00
|
|
|
run: |
|
|
|
|
cat > Dockerfile <<EOF
|
|
|
|
FROM scratch
|
|
|
|
COPY ./cloud-controller-manager /cloud-controller-manager
|
|
|
|
EOF
|
2023-01-18 04:15:58 -05:00
|
|
|
|
2022-08-03 05:46:11 -04:00
|
|
|
- name: Build and push container image
|
|
|
|
id: build
|
2023-06-20 07:39:32 -04:00
|
|
|
uses: docker/build-push-action@2eb1c1961a95fc15694676618e422e8ba1d63825 # v4.1.1
|
2022-08-03 05:46:11 -04:00
|
|
|
with:
|
2023-08-16 04:42:40 -04:00
|
|
|
context: ./cloud-provider-gcp
|
|
|
|
push: ${{ github.ref_name == 'main' }}
|
2022-08-03 05:46:11 -04:00
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|