0

Buildah scripts typically use shell. You can see an example of a script here,

#!/bin/sh
ctr=$(buildah from alpine:3)
buildah commit "$ctr" myAlpineImage

Let's say I have such a shell script that produces an image "myAlpineImage". How can I use GitHub CI to automate the creation of this image, and preferably uploading it to GitHub Container Registry?

2
  • What have you tried so far? As it stands, this question is very broad, and by narrowing down the scope to solving what you've tried thus far, you will be much more likely to get an accurate response. – Preston Martin Mar 11 at 17:32
  • @PrestonMartin I self answered. – Evan Carroll Mar 11 at 20:02
0

Here is what I did, I create a Makefile that includes my own method of image creation,

.PHONY: image clean image-release
image: image-release

image-release:
    cargo build --release
    buildah unshare ./image/distroless.sh release

clean:
    cargo -v clean

For this purpose the only thing that matters is the image created by ./image/distroless.sh matches the action (redhat-actions/push-to-registry) in the following flow. We'll continue using the name myAlpineImage as in the question,

name: Distroless Image Creation

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

env:
  CARGO_TERM_COLOR: always

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Download and create image.
      run: make image-release
    - name: Push To Registry
      uses: redhat-actions/push-to-registry@v2.1.1
      with:
        image: myAlpineImage
        tags: latest
        registry: ghcr.io/evancarroll/project
        username: evancarroll
        password: ${{ secrets.GHCR_TOKEN }}

You can see here we make the call to make image-release which calls the buildah script and makes the image rootless.

Then I added the secret for GHCR_TOKEN to my repo. The token is generated in the "Settings / Developer settings / Personal access" tokens on github..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.