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
|
2023-12-20 10:10:35 -05:00
|
|
|
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
2023-08-16 04:42:40 -04:00
|
|
|
|
|
|
|
- name: Checkout kubernetes/cloud-provider-gcp
|
2023-12-20 10:10:35 -05:00
|
|
|
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
2023-08-16 04:42:40 -04:00
|
|
|
with:
|
|
|
|
repository: "kubernetes/cloud-provider-gcp"
|
|
|
|
path: "cloud-provider-gcp"
|
|
|
|
fetch-depth: 0
|
|
|
|
|
|
|
|
- name: Setup Go environment
|
2023-12-21 06:54:39 -05:00
|
|
|
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
|
2023-08-16 04:42:40 -04:00
|
|
|
with:
|
2024-03-06 07:45:06 -05:00
|
|
|
go-version: "1.22.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
|
2023-12-20 10:10:35 -05:00
|
|
|
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
2023-08-16 04:42:40 -04:00
|
|
|
|
2023-01-18 04:15:58 -05:00
|
|
|
- name: Checkout kubernetes/cloud-provider-gcp
|
2023-12-20 10:10:35 -05:00
|
|
|
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
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
|
2024-02-21 09:29:06 -05:00
|
|
|
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
|
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
|
2024-02-21 09:29:06 -05:00
|
|
|
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0
|
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 }}
|