Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.github: add workflow to build beta images #18052

Merged
merged 1 commit into from
Nov 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
pchaigno marked this conversation as resolved.
Show resolved Hide resolved

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 }}
aanm marked this conversation as resolved.
Show resolved Hide resolved
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