Skip to content

Commit

Permalink
Merge pull request #1 from kron4eg/gh-actions
Browse files Browse the repository at this point in the history
Multi-platform builds of kubernetes/ingress-gce using github actions
  • Loading branch information
ScheererJ authored Sep 19, 2024
2 parents 2e38ea8 + 821b9a2 commit add0534
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 6 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Build, push and release
on:
workflow_dispatch:
inputs:
release_tag:
description: 'New release git/docker tag to publish'
required: true
type: string
ingress_gce_version:
description: 'kubernetes/ingress-gce version to checkout on build'
required: true
type: string

env:
IMAGE_REGISTRY: ghcr.io
IMAGE_REPO: gardener/ingress-gce
IMAGE_TAG: ${{ inputs.release_tag }}
PLATFORMS: linux/amd64,linux/arm64

defaults:
run:
shell: bash

jobs:
build-push-release:
permissions:
# give GITHUB_TOKEN write permissions
packages: write
contents: write
id-token: write
runs-on: ubuntu-latest
steps:
- name: Checkout the gardener/ingress-gce repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # https://github.com/actions/checkout/releases/tag/v4.1.7

- name: Checkout the kubernetes/ingress-gce repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # https://github.com/actions/checkout/releases/tag/v4.1.7
with:
repository: 'kubernetes/ingress-gce'
path: './ingress-gce'
persist-credentials: false
ref: '${{ inputs.ingress_gce_version }}'

- name: Login to registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # https://github.com/docker/login-action/releases/tag/v3.3.0
with:
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker setup buildx
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # https://github.com/docker/setup-buildx-action/releases/tag/v3.6.1
with:
platforms: ${{ env.PLATFORMS }}

- name: Build and push Docker images
uses: docker/build-push-action@5cd11c3a4ced054e52742c5fd54dca954e0edd85 # https://github.com/docker/build-push-action/releases/tag/v6.7.0
with:
context: .
tags: |
${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_REPO }}:${{ env.IMAGE_TAG }}
push: true
platforms: ${{ env.PLATFORMS }}

- name: Create new release
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # https://github.com/ncipollo/release-action/releases/tag/v1.14.0
with:
tag: ${{ inputs.release_tag }}
makeLatest: true
body: |
## Docker Images
* ingress-gce: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_REPO }}:${{ env.IMAGE_TAG }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ingress-gce
10 changes: 5 additions & 5 deletions .reuse/dep5
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: Gardener <repo name>
Upstream-Name: Gardener ingress-gce
Upstream-Contact: The Gardener project <[email protected]>
Source: https://github.com/gardener/<repo name>
Source: https://github.com/gardener/ingress-gce

# --------------------------------------------------
# source code
Expand All @@ -21,9 +21,9 @@ License: CC-BY-4.0
# third-party

# --- copied source code ---
# Files:
# Copyright:
# License:
# Files:
# Copyright:
# License:

# --- vendor folder dependencies ---
# Files:
Expand Down
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM golang:1.22.7 AS builder
ENV CGO_ENABLED=0
COPY . .
WORKDIR ingress-gce

Check warning on line 4 in Dockerfile

View workflow job for this annotation

GitHub Actions / build-push-release

Relative workdir without an absolute workdir declared within the build can have unexpected results if the base image changes

WorkdirRelativePath: Relative workdir "ingress-gce" can have unexpected results if the base image changes More info: https://docs.docker.com/go/dockerfile/rule/workdir-relative-path/
RUN go install -v ./cmd/glbc

# ### actual container
FROM gcr.io/distroless/static:latest
COPY --from=builder /go/bin/glbc /glbc

ENTRYPOINT ["/glbc"]
25 changes: 25 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Gardener contributors
#
# SPDX-License-Identifier: Apache-2.0

.ONESHELL:
.SHELLFLAGS := -eu -o pipefail -c
SHELL := bash
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
IMAGE_REPOSITORY := ghcr.io/gardener/ingress-gce
IMAGE_TAG := $(shell git describe --tags --always)

.PHONY: build
build: docker-image

.PHONY: release
release: build docker-login

.PHONY: docker-image
docker-image:
@docker buildx build -t $(IMAGE_REPOSITORY):$(IMAGE_TAG) --platform linux/arm64,linux/amd64 --load .

.PHONY: docker-login
docker-login:
@gcloud auth activate-service-account --key-file .kube-secrets/gcr/gcr-readwrite.json
41 changes: 40 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,46 @@
# <repo name>
# ingress-gce

[![reuse compliant](https://reuse.software/badge/reuse-compliant.svg)](https://reuse.software/)

This repository is dedicated to building [kubernetes/ingress-gce](https://github.com/kubernetes/ingress-gce) images for Gardener project.

## Building a new Release

Once in a while a new release of the
[kubernetes/ingress-gce](https://github.com/kubernetes/ingress-gce) will be
released and we need to build new container image. In order to trigger the new
release one can use two options, tigger the release workflow from the web UI or
from CLI, see more at the
https://docs.github.com/en/actions/managing-workflow-runs-and-deployments/managing-workflow-runs/manually-running-a-workflow.


### Trigger the release from the Github web UI

* Navigate to Actions https://github.com/gardener/ingress-gce/actions
* Select **Build, push and release** worflow
* Click **Run worflow** button
* Input `New release tag to publish` and `kubernetes/ingress-gce version to build`
* Click green **Run worflow** button

### Trigger the release from gh CLI

```shell
gh workflow run release.yaml -f release_tag=<NEW_TAG_TO_RELEASE> -f ingress_gce_version=<TAG_FROM_UPSTREAM>
```

Where `NEW_TAG_TO_RELEASE` is a new tag for the GH release and image to be
created and `TAG_FROM_UPSTREAM` is existing target tag to build from
[kubernetes/ingress-gce](https://github.com/kubernetes/ingress-gce).

Example:

```shell
gh workflow run release.yaml -f release_tag=v1.30.0-sap.0 -f ingress_gce_version=v1.30.0
```

Will build [kubernetes/ingress-gce](https://github.com/kubernetes/ingress-gce) binary from v1.30.0 git tag, and publish docker image: `ghcr.io/gardener/ingress-gce:v1.30.0-sap.0`


## How to use this repository template

This template repository can be used to seed new git repositories in the gardener github organisation.
Expand Down

0 comments on commit add0534

Please sign in to comment.