Answers: <p>Here is what I did, I create a Makefile that includes my own method of image creation,</p>
  <pre><code>.PHONY: image clean image-release
  image: image-release
  
  image-release:
      cargo build --release
      buildah unshare ./image/distroless.sh release
  
  clean:
      cargo -v clean
  </code></pre>
  <p>For this purpose the only thing that matters is the image created by <code>./image/distroless.sh</code> matches the action (<code>redhat-actions/push-to-registry</code>) in the following flow. We'll continue using the name <code>myAlpineImage</code> as in the question,</p>
  <pre><code>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 }}
  </code></pre>
  <p>You can see here we make the call to <code>make image-release</code> which calls the buildah script and makes the image rootless.</p>
  <p>Then I added the secret for <code>GHCR_TOKEN</code> to my repo. The token is generated in the <a href="https://github.com/settings/tokens" rel="nofollow noreferrer">&quot;Settings / Developer settings / Personal access&quot; tokens on github.</a>.</p>
  
Answers: CC BY-SA 4.0
Answers: 2021-03-11T20:02:08.193Z
Answers: 2021-03-11T20:02:08.193Z
Answers: Evan Carroll
Body: <p><a href="https://buildah.io/" rel="nofollow noreferrer">Buildah</a> scripts typically use shell. You can see an example of a script here,</p>
  <pre><code>#!/bin/sh
  ctr=$(buildah from alpine:3)
  buildah commit &quot;$ctr&quot; myAlpineImage
  </code></pre>
  <p>Let's say I have such a shell script that produces an image &quot;myAlpineImage&quot;. How can I use GitHub CI to automate the creation of this image, and preferably uploading it to GitHub Container Registry?</p>
  
Comments: CC BY-SA 4.0
Comments: 2021-03-11T17:32:11.397Z
Comments: 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.
Comments: Preston Martin
Comments: CC BY-SA 4.0
Comments: 2021-03-11T20:02:14.580Z
Comments: @PrestonMartin I self answered.
Comments: Evan Carroll
Tags: <containers><github><github-actions>
Title: How can I use a buildah script for image generation using GitHub Actions?
UserDisplayName: Evan Carroll
ThreadText: # How can I use a buildah script for image generation using GitHub Actions?
  
  (Asked by: username_0 on 2021-03-11)
  
  [Buildah](https://buildah.io/) 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?
  
  **Tags:** containers, github, github-actions
  
  > **Comments:**
  > **username_1**: 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.  
  > **username_0**: @username_1 I self answered.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2021-03-11. Score: 1 | Accepted answer
  
  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/username_0/project
          username: username_0
          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.](https://github.com/settings/tokens).
  
  
  ---
  
  