Skip to content

Merge pull request #37 from ppc64le-cloud/dependabot/github_actions/a… #541

Merge pull request #37 from ppc64le-cloud/dependabot/github_actions/a…

Merge pull request #37 from ppc64le-cloud/dependabot/github_actions/a… #541

name: Docker
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
on:
workflow_dispatch:
inputs:
k8s-version:
description: 'The kubernetes version to be used for building node image.'
default: 'master'
required: false
type: string
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
permissions:
packages: write
strategy:
fail-fast: false
env:
# Use docker.io for Docker Hub if empty
REGISTRY: quay.io
# github.repository as <account>/<repo>
IMAGE_NAME: powercloud/kind-node
# Until variables are available across different github_events as a feature,
# this operation can set a default value for k8s-version to 'master'
# https://github.com/orgs/community/discussions/26322#discussioncomment-3251442
K8S-VERSION: ${{ inputs.k8s-version || 'v1.31.0' }}
steps:
- name: Checkout repository
uses: actions/[email protected]
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Set variables
run: |
KIND_VERSION=$(cat KIND_VERSION)
BASE_IMAGE=$(cat BASE_IMAGE)
echo "KIND_VERSION=$KIND_VERSION" >> $GITHUB_ENV
echo "BASE_IMAGE=$BASE_IMAGE" >> $GITHUB_ENV
export PATH=$PATH:$(go env GOPATH)/bin
echo "PATH=$PATH" >> $GITHUB_ENV
- name: Build and install kind - ${{ env.KIND_VERSION }}
run: |
# The runner has kind pre-installed, removing the same to install the preferred version.
rm -rf $(which kind)
git clone --depth 1 --branch ${{ env.KIND_VERSION }} https://github.com/kubernetes-sigs/kind.git
pushd kind
git apply ../build-ppc64le.patch
popd
make -C kind install
- name: Build kind-node image - ${{ env.K8S-VERSION}}
run: |
kind build node-image --type url https://dl.k8s.io/${{ env.K8S-VERSION }}/kubernetes-server-linux-ppc64le.tar.gz --arch ppc64le --image ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.K8S-VERSION }} --base-image ${{ env.BASE_IMAGE }}
- name: Publish node image - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.K8S-VERSION }}
# Modifying or adding new changes to the workflow does not necessarily require the built image to be pushed.
# Images can solely be built through workflow dispatch.
if: github.event_name != 'pull_request' && github.event_name != 'push'
run: |
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.K8S-VERSION }}