Build and push controller images #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and push controller images | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- api/** | |
- controllers/** | |
- ./main.go | |
- ./go.mod | |
- ./go.sum | |
- config/** | |
- ./Dockerfile | |
- ./Makefile | |
- bundle/** | |
workflow_dispatch: | |
env: | |
VERSION: '0.0.1' | |
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }} | |
jobs: | |
build-push-bundle: | |
runs-on: ubuntu-latest | |
env: | |
IMAGE_NAME: ghcr.io/foundation-model-stack/ocp-efa-operator | |
BUNDLE_IMAGE_NAME: ghcr.io/foundation-model-stack/ocp-efa-operator-bundle | |
CHANNELS: stable | |
DEFAULT_CHANNEL: stable | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-go@v2 | |
with: | |
go-version: '1.21' | |
- name: set ARCH and OS | |
run: | | |
echo "ARCH=$(case $(uname -m) in x86_64) echo -n amd64 ;; aarch64) echo -n arm64 ;; *) echo -n $(uname -m) ;; esac)" >> $GITHUB_ENV | |
echo "OS=$(uname | awk '{print tolower($0)}')" >> $GITHUB_ENV | |
echo "OPERATOR_SDK_DL_URL=https://github.com/operator-framework/operator-sdk/releases/download/v1.23.0" >> $GITHUB_ENV | |
- name: download operator-sdk | |
run: curl -LO ${{ env.OPERATOR_SDK_DL_URL }}/operator-sdk_${{ env.OS }}_${{ env.ARCH }} | |
- name: move operator-sdk to binary path | |
run: chmod +x operator-sdk_${{ env.OS }}_${{ env.ARCH }} && sudo mv operator-sdk_${{ env.OS }}_${{ env.ARCH }} /usr/local/bin/operator-sdk | |
- name: Tidy | |
run: | | |
go mod tidy | |
- name: Make bundle | |
run: make bundle IMG=${{ env.IMAGE_NAME }}:v${{ env.VERSION }} | |
- name: Set up Docker | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to Docker | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ secrets.GH_USERNAME }} | |
password: ${{ secrets.GH_TOKEN }} | |
- name: Build and push bundle | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
push: true | |
tags: | | |
${{ env.BUNDLE_IMAGE_NAME }}:latest | |
${{ env.BUNDLE_IMAGE_NAME }}:v${{ env.VERSION }} | |
file: ./bundle.Dockerfile | |
build-push-controller: | |
runs-on: ubuntu-latest | |
env: | |
IMAGE_NAME: ghcr.io/foundation-model-stack/ocp-efa-operator | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-go@v2 | |
with: | |
go-version: '1.21' | |
- name: Tidy | |
run: | | |
go mod tidy | |
make generate fmt vet | |
- name: Set up Docker | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to Docker | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ secrets.GH_USERNAME }} | |
password: ${{ secrets.GH_TOKEN }} | |
- name: Build and push controller | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
push: true | |
tags: | | |
${{ env.IMAGE_NAME }}:${{ github.sha }}-${{ github.run_number }} | |
${{ env.IMAGE_NAME }}:latest | |
${{ env.IMAGE_NAME }}:v${{ env.VERSION }} | |
file: ./Dockerfile |