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

Operator buider ci add #347

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions .github/workflows/operator-builder-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@

name: operator-builder-ci
on:
push:
branches:
- develop
- main
pull_request:
workflow_dispatch:
inputs:
production:
description: 'Click the checkbox for production images'
default: false
type: boolean
required: false
env:
IMAGE_VERSION: 'v0.9.1'
jobs:
prepare_env:
name: "Prepare env"
runs-on: ubuntu-latest
env:
PRODUCTION: "${{ inputs.production }}"
BUILD_NUMBER: "${{ github.run_number }}"
GITHUB_SHA: "${{ github.sha }}"
PROD_REPOSITORY: csiblock/ibm-block-csi-operator
STAGING_REPOSITORY: csiblock/ibm-block-csi-operator-staging
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Setup dependencies
id: setup_dependencies
run: |
build/ci/github_actions/setup_ci_dependencies.sh
outputs:
repository: "${{ steps.setup_dependencies.outputs.repository }}"
specific_tag: "${{ steps.setup_dependencies.outputs.specific_tag }}"
global_tag: "${{ steps.setup_dependencies.outputs.global_tag }}"

build_and_push_images:
name: "Build and push images"
runs-on: ubuntu-latest
env:
REGISTRY: quay.io
needs:
- prepare_env
steps:
- name: Checkout
uses: actions/[email protected]
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
${{ env.REGISTRY }}/${{ needs.prepare_env.outputs.repository }}
tags: |
type=raw,value=${{ needs.prepare_env.outputs.global_tag }}
type=raw,value=${{ needs.prepare_env.outputs.specific_tag }}
labels: |
commit=${{ github.sha }}
- name: Login to quay.io
uses: docker/login-action@v2
with:
registry: quay.io
username: '${{ secrets.CSIBLOCK_DOCKER_REGISTRY_USERNAME }}'
password: '${{ secrets.CSIBLOCK_DOCKER_REGISTRY_PASSWORD }}'
- name: Build and push operator images
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/ppc64le,linux/s390x
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: build/Dockerfile.operator
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
VERSION: ${{ env.IMAGE_VERSION }}
BUILD_NUMBER: ${{ github.run_number }}
- name: show chosen image
run: |
echo ${{ env.REGISTRY }}/${{ needs.prepare_env.outputs.repository }}:${{ needs.prepare_env.outputs.specific_tag }}
echo ${{ env.REGISTRY }}/${{ needs.prepare_env.outputs.repository }}:${{ needs.prepare_env.outputs.global_tag }}
- name: save image names
run: |
echo ${{ env.REGISTRY }}/${{ needs.prepare_env.outputs.repository }} >> /tmp/images.txt
echo ${{ needs.prepare_env.outputs.specific_tag }} >> /tmp/images.txt
echo ${{ needs.prepare_env.outputs.global_tag }} >> /tmp/images.txt
- uses: actions/upload-artifact@v3
with:
name: images
path: /tmp/images.txt
retention-days: 90
26 changes: 26 additions & 0 deletions build/ci/github_actions/setup_ci_dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash -xe
set +o pipefail

triggering_branch=$(echo ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}})
image_version=${IMAGE_VERSION}
build_number=${BUILD_NUMBER}
commit_hash=${GITHUB_SHA:0:7}
specific_tag="${image_version}_b${build_number}_${commit_hash}_${triggering_branch}"


if [ "$triggering_branch" == "develop" ]; then
global_tag=latest
else
global_tag=${triggering_branch}
fi

if [ "$PRODUCTION" = true ]; then
repository=${PROD_REPOSITORY}
global_tag=${image_version}
else
repository=${STAGING_REPOSITORY}
fi

echo "repository=${repository}" >> $GITHUB_OUTPUT
echo "specific_tag=${specific_tag}" >> $GITHUB_OUTPUT
echo "global_tag=${global_tag}" >> $GITHUB_OUTPUT
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ metadata:
"operator": "In",
"values": [
"amd64"
"s390x",
"ppc64le"
]
}
]
Expand All @@ -61,6 +63,8 @@ metadata:
"operator": "In",
"values": [
"amd64"
"s390x",
"ppc64le"
]
}
]
Expand Down Expand Up @@ -158,6 +162,8 @@ metadata:
"operator": "In",
"values": [
"amd64"
"s390x",
"ppc64le"
]
}
]
Expand Down Expand Up @@ -622,6 +628,8 @@ spec:
operator: In
values:
- amd64
- s390x
- ppc64le
containers:
- name: ibm-block-csi-operator
resources:
Expand Down