Skip to content

Commit

Permalink
.github: add workflow to build beta images
Browse files Browse the repository at this point in the history
With this new workflow, developers will be able to release beta features
that are created on top of an existing release.

The workflow to create a new beta image is as follow:

1. Push a branch into Cilium's repository with the name:
   `feature/<stable-branch>/<feature-name>` where `<stable-branch>`
   represents the branch where the feature is based on and
   `<feature-name>` represents the name of the feature being released.
2. Trigger the workflow by going into [1], use the workflow from
   `feature/<stable-branch>/<feature-name>` branch and write an image
   tag name.
   The tag name should be in the format `vX.Y.Z-<feature-name>` where
   `vX.Y.Z` is the version on which the branch is built on, and
   `<feature-name>` the name of the feature.
3. Ping one of the maintainers or anyone from the cilium-build team to
   approve the build and release process of this feature.

[1] https://github.com/cilium/cilium/actions/workflows/build-images-beta.yaml

Signed-off-by: André Martins <andre@cilium.io>
  • Loading branch information
aanm committed Nov 30, 2021
1 parent fcd0039 commit 420028f
Showing 1 changed file with 129 additions and 0 deletions.
129 changes: 129 additions & 0 deletions .github/workflows/build-images-beta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
name: Beta Image Release Build

on:
workflow_dispatch:
inputs:
tag:
description: 'Docker Image Tag'
required: true

permissions: read-all

jobs:
build-and-push:
if: ${{ github.repository == 'cilium/cilium' }}
environment: release-beta-images
runs-on: ubuntu-20.04
strategy:
matrix:
include:
- name: cilium
dockerfile: ./images/cilium/Dockerfile

- name: operator
dockerfile: ./images/operator/Dockerfile

- name: operator-aws
dockerfile: ./images/operator/Dockerfile

- name: operator-azure
dockerfile: ./images/operator/Dockerfile

- name: operator-alibabacloud
dockerfile: ./images/operator/Dockerfile

- name: operator-generic
dockerfile: ./images/operator/Dockerfile

- name: hubble-relay
dockerfile: ./images/hubble-relay/Dockerfile

- name: clustermesh-apiserver
dockerfile: ./images/clustermesh-apiserver/Dockerfile

- name: docker-plugin
dockerfile: ./images/cilium-docker-plugin/Dockerfile

steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@94ab11c41e45d028884a99163086648e898eed25

- name: Login to quay.io
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: quay.io
username: ${{ secrets.QUAY_BETA_USERNAME }}
password: ${{ secrets.QUAY_BETA_PASSWORD }}

- name: Getting image tag
id: tag
run: |
echo ::set-output name=tag::${GITHUB_REF##*/}
- name: Checking if tag already exists
id: tag-in-repositories
shell: bash
run: |
if docker buildx imagetools inspect quay.io/${{ github.repository_owner }}/${{ matrix.name }}-beta:${{ github.event.inputs.tag }} &>/dev/null; then
echo "Tag already exists!"
exit 1
fi
- name: Checkout Source Code
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
with:
persist-credentials: false

- name: Release Build ${{ matrix.name }}
uses: docker/build-push-action@a66e35b9cbcf4ad0ea91ffcaf7bbad63ad9e0229
id: docker_build_release
with:
context: .
file: ${{ matrix.dockerfile }}
push: true
platforms: linux/amd64,linux/arm64
tags: |
quay.io/${{ github.repository_owner }}/${{ matrix.name }}-beta:${{ github.event.inputs.tag }}
quay.io/${{ github.repository_owner }}/${{ matrix.name }}-ci:${{ github.sha }}
build-args: |
OPERATOR_VARIANT=${{ matrix.name }}
- name: Image Release Digest
shell: bash
run: |
mkdir -p image-digest/
echo "## ${{ matrix.name }}" > image-digest/${{ matrix.name }}.txt
echo "" >> image-digest/${{ matrix.name }}.txt
echo "\`quay.io/${{ github.repository_owner }}/${{ matrix.name }}-beta:${{ github.event.inputs.tag }}@${{ steps.docker_build_release.outputs.digest }}\`" >> image-digest/${{ matrix.name }}.txt
echo "\`quay.io/${{ github.repository_owner }}/${{ matrix.name }}-ci:${{ github.sha }}@${{ steps.docker_build_release.outputs.digest }}\`" >> image-digest/${{ matrix.name }}.txt
echo "" >> image-digest/${{ matrix.name }}.txt
# Upload artifact digests
- name: Upload artifact digests
uses: actions/upload-artifact@27121b0bdffd731efa15d66772be8dc71245d074
with:
name: image-digest ${{ matrix.name }}
path: image-digest
retention-days: 1

image-digests:
if: ${{ github.repository == 'cilium/cilium' }}
name: Display Digests
runs-on: ubuntu-20.04
needs: build-and-push
steps:
- name: Downloading Image Digests
shell: bash
run: |
mkdir -p image-digest/
- name: Download digests of all images built
uses: actions/download-artifact@3be87be14a055c47b01d3bd88f8fe02320a9bb60
with:
path: image-digest/

- name: Image Digests Output
shell: bash
run: |
cd image-digest/
find -type f | sort | xargs -d '\n' cat

0 comments on commit 420028f

Please sign in to comment.