Skip to content

Commit

Permalink
Add github workflow to build and push kanister image (#1991)
Browse files Browse the repository at this point in the history
* Make workflow to run on-demand only
* Added docs about kanister build image workflow
  • Loading branch information
shahpratikr authored Apr 10, 2023
1 parent 700d7c2 commit d0d0a3d
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
50 changes: 50 additions & 0 deletions .github/workflows/kanister-image-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: build-kanister-image

on:
workflow_dispatch:
inputs:
tag:
description: 'Image tag in the format vx.x.x'
required: true
type: string

env:
REGISTRY: ghcr.io
IMAGE_NAME: kanisterio/build

jobs:
# TODO: Enable following when we want to automate this workflow on push to master branch
# check-files:
# runs-on: ubuntu-latest
# outputs:
# changed: ${{ steps.changed-files.outputs.any_changed }}
# steps:
# - uses: actions/checkout@v3
# with:
# fetch-depth: 0
# - uses: tj-actions/changed-files@v35
# name: Get changed files
# id: changed-files
# with:
# files: docker/build/Dockerfile

build:
runs-on: ubuntu-latest
# TODO: Uncomment following when we enable check-file job
# needs: check-files
# if: needs.check-files.outputs.changed == 'true'
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: "{{defaultContext}}:docker/build"
push: true
tags: ${{ env.IMAGE_NAME }}:${{ inputs.tag }}
12 changes: 11 additions & 1 deletion BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The [Makefile](Makefile) provides a set of targets to help simplify the build
tasks. To ensure cross-platform consistency, many of these targets use Docker
to spawn build containers based on the `ghcr.io/kanisterio/build` public image.

For `make test` to succeed, a valid `kubeconfig` file must be found at
For `make test` to succeed, a valid `kubeconfig` file must be found at
`$HOME/.kube/config`. See the Docker command that runs `make test` [here](https://github.com/kanisterio/kanister/blob/fa04d77eb6f5c92521d1413ddded385168f39f42/Makefile#L219).

Use the `check` target to ensure your development environment has the necessary
Expand Down Expand Up @@ -132,3 +132,13 @@ see how to write a new Kanister Function.

Don't forget to update the documentation at `docs/functions.rst` with
configuration information and examples to show off your new function.

## Build Kanister image

The Kanister build image [workflow](.github/workflows/kanister-image-build.yaml)
is used to build and push a new Kanister build image (`ghcr.io/kanisterio/build`).
It is an on-demand workflow and needs to be run manually. This workflow expects
`image tag` value as an input.

The author updating the build image tag must raise a separate PR to update this
value for it to be used in the build process. It should be set it [here](https://github.com/kanisterio/kanister/blob/master/Makefile#L61).

0 comments on commit d0d0a3d

Please sign in to comment.