Skip to content

Commit

Permalink
👷 Use buildah in docker CI workflows (#425)
Browse files Browse the repository at this point in the history
* try buildah in CI

* add build-args

* debug: push the build

* fix push action args

* debug: all archs

* try fix missing tag list in notif

* remove restore-key

* try make more like docs

* sigh

* sigh

* debug: force large runner

* debug: force small runner

* Revert debug commits

This reverts commit 1aafbec.

Revert "debug: force small runner"

This reverts commit 51186f0.

Revert "debug: force large runner"

This reverts commit de65e87.

Revert "debug: all archs"

This reverts commit cac30fa.
  • Loading branch information
aaronleopold authored Aug 31, 2024
1 parent bef46c8 commit afe389c
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 27 deletions.
47 changes: 32 additions & 15 deletions .github/actions/build-docker/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ inputs:
tags:
description: 'List of tags to assigned to the image'
default: 'nightly'
platforms:
archs:
description: 'List of platforms to build'
required: true
discord-webhook:
Expand All @@ -33,12 +33,13 @@ runs:

- name: Format tags
run: |
echo "TAGS=$(echo ${{ inputs.tags }} | sed -e 's/,/,aaronleopold\/stump:/g' | sed -e 's/^/aaronleopold\/stump:/')" >> $GITHUB_ENV
echo "FORMATTED_TAGS=$(echo ${{ inputs.tags }} | sed -e 's/,/,aaronleopold\/stump:/g' | sed -e 's/^/aaronleopold\/stump:/')" >> $GITHUB_ENV
shell: bash

- name: Sanity check
run: |
echo "TAGS=${{ env.TAGS }}"
echo "TAGS=${{ inputs.tags }}"
echo "FORMATTED_TAGS=${{ env.FORMATTED_TAGS }}"
echo "GIT_REV=${{ env.GIT_REV }}"
shell: bash

Expand All @@ -53,7 +54,7 @@ runs:
- name: Check QEMU requirement
id: check-qemu
run: |
if [[ ${{ inputs.platforms }} == *"arm"* ]]; then
if [[ ${{ inputs.archs }} == *"arm"* ]]; then
echo "SETUP_QEMU=1" >> $GITHUB_OUTPUT
else
echo "SETUP_QEMU=0" >> $GITHUB_OUTPUT
Expand All @@ -66,35 +67,51 @@ runs:
with:
platforms: linux/arm64

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Install podman
- name: Install podman and buildah
if: runner.environment != 'self-hosted'
run: |
sudo apt-get update
sudo apt-get install -y podman
sudo apt-get install -y podman buildah
shell: bash

- name: Run podman buildx
- name: Run buildah build
id: build
uses: redhat-actions/buildah-build@v2
with:
image: stump
tags: ${{ inputs.tags }}
archs: ${{ inputs.archs }}
build-args: |
GIT_REV=${{ env.GIT_REV }}
RUN_PRISMA_GENERATE=false
containerfiles: |
./docker/Dockerfile
- name: Echo build outputs
run: |
ENGINE=podman PLATFORMS="${{ inputs.platforms }}" TAGS="${{ env.TAGS }}" GIT_REV="${{ env.GIT_REV }}" PUSH="${{ inputs.push }}" ./docker/build.sh
echo "${{ toJSON(steps.build.outputs) }}"
shell: bash

- name: Push to registry
id: push
if: ${{ success() && inputs.push == 'true' }}
uses: redhat-actions/push-to-registry@v2
with:
image: aaronleopold/stump
tags: ${{ env.TAGS }}
image: ${{ steps.build.outputs.image }}
tags: ${{ steps.build.outputs.tags }}
username: ${{ inputs.username }}
password: ${{ inputs.password }}
registry: docker.io
registry: docker.io/aaronleopold

- name: Echo push outputs
run: |
echo "${{ toJSON(steps.push.outputs) }}"
shell: bash

- name: Discord notification
if: ${{ success() && inputs.push == 'true' && inputs.discord-webhook != '' }}
env:
DISCORD_WEBHOOK: ${{ inputs.discord-webhook }}
uses: 'Ilshidur/[email protected]'
with:
args: 'Successfully pushed the following image tags to registry: ${{ env.TAGS }}'
args: 'Successfully pushed the following image tags to registry: ${{ steps.build.outputs.tags }}'
3 changes: 1 addition & 2 deletions .github/actions/setup-rust/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ runs:
- name: Save Prisma client
id: cache-prisma-save
if: ${{ steps.cache-prisma-restore.outputs.cache-hit != 'true' }}
uses: actions/cache/save@v3
uses: actions/cache/save@v4
with:
path: core/src/prisma.rs
key: ${{ runner.os }}-prisma-${{ hashFiles('**/schema.prisma') }}
restore-keys: ${{ runner.os }}-prisma-${{ hashFiles('**/schema.prisma') }}
3 changes: 1 addition & 2 deletions .github/workflows/experimental.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,5 @@ jobs:
tags: 'experimental'
load: ${{ github.event_name == 'pull_request' }}
push: ${{ github.event_name == 'push' }}
platforms: 'linux/amd64'
# platforms: 'linux/arm64/v8,linux/arm/v7,linux/amd64'
archs: 'linux/amd64'
discord-webhook: ${{ secrets.DISCORD_WEBHOOK }}
6 changes: 3 additions & 3 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ jobs:
echo "PUSH=${{ github.event_name == 'push' }}" >> $GITHUB_ENV
if [[ ${{ github.event_name }} == 'pull_request' ]]; then
echo "PLATFORMS=linux/amd64" >> $GITHUB_ENV
echo "ARCHS=amd64" >> $GITHUB_ENV
else
echo "PLATFORMS=linux/arm64/v8,linux/amd64" >> $GITHUB_ENV
echo "ARCHS=arm64,amd64" >> $GITHUB_ENV
fi
- name: Setup and build docker image
Expand All @@ -67,5 +67,5 @@ jobs:
tags: 'nightly'
load: ${{ env.LOAD }}
push: ${{ env.PUSH }}
platforms: ${{ env.PLATFORMS }}
archs: ${{ env.ARCHS }}
discord-webhook: ${{ secrets.DISCORD_WEBHOOK }}
10 changes: 5 additions & 5 deletions .github/workflows/release_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,24 @@ jobs:
outputs:
load: ${{ steps.configure.outputs.load }}
push: ${{ steps.configure.outputs.push }}
platforms: ${{ steps.configure.outputs.platforms }}
archs: ${{ steps.configure.outputs.archs }}
steps:
- name: Configure environment
id: configure
run: |
if [[ ${{ github.event.pull_request.merged }} == true ]]; then
echo "push=true" >> $GITHUB_OUTPUT
echo "load=false" >> $GITHUB_OUTPUT
echo "platforms=linux/arm64/v8,linux/amd64" >> $GITHUB_OUTPUT
echo "archs=arm64,amd64" >> $GITHUB_OUTPUT
else
echo "push=false" >> $GITHUB_OUTPUT
echo "load=true" >> $GITHUB_OUTPUT
echo "platforms=linux/amd64" >> $GITHUB_OUTPUT
echo "archs=amd64" >> $GITHUB_OUTPUT
fi
- name: Print the configuration
run: |
echo "Platforms: ${{ steps.configure.outputs.platforms }}"
echo "Archs: ${{ steps.configure.outputs.archs }}"
echo "Load: ${{ steps.configure.outputs.load }}"
echo "Push: ${{ steps.configure.outputs.push }}"
Expand All @@ -84,5 +84,5 @@ jobs:
tags: ${{ needs.parse-semver.outputs.tags }}
load: ${{ needs.push-or-load.outputs.load }}
push: ${{ needs.push-or-load.outputs.push }}
platforms: ${{ needs.push-or-load.outputs.platforms }}
archs: ${{ needs.push-or-load.outputs.archs }}
discord-webhook: ${{ secrets.DISCORD_WEBHOOK }}

0 comments on commit afe389c

Please sign in to comment.