Skip to content

Commit

Permalink
Simplify image build (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
fwilhe authored Sep 16, 2024
1 parent 0918a08 commit 1c00791
Showing 1 changed file with 56 additions and 28 deletions.
84 changes: 56 additions & 28 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,36 +54,64 @@ jobs:
runs-on: ubuntu-24.04
needs:
- build
if: github.ref == 'refs/heads/main'
env:
IMAGE_NAME: ghcr.io/gardenlinux/glvd-api
IMAGE_TAG: latest

steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'sapmachine'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64,linux/arm64
- name: Login to GitHub Container Registry
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: token
password: ${{ github.token }}
- name: Checkout repo
uses: actions/checkout@v4

- run: mkdir -p build
- uses: actions/download-artifact@v4
with:
name: build-artifacts
path: build
- run: docker buildx build --file=Containerfile --platform=linux/amd64,linux/arm64 --push --tag=ghcr.io/gardenlinux/glvd-api:edge .
# - run: podman build --platform linux/amd64,linux/arm64 --manifest ghcr.io/gardenlinux/glvd-api:edge .
# - run: podman login -u token -p ${{ github.token }} ghcr.io
# - run: podman push ghcr.io/gardenlinux/glvd-api:edge
# - run: podman push ghcr.io/gardenlinux/glvd-api:edge_bare
- run: mkdir -p build
- name: Download built jar
uses: actions/download-artifact@v4
with:
name: build-artifacts
path: build

- name: Install qemu dependency for multi-arch build
run: |
sudo apt-get update
sudo apt-get install -y qemu-user-static
- name: Build Image
id: build_image
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.IMAGE_NAME }}
tags: ${{ env.IMAGE_TAG }}
platforms: linux/amd64, linux/arm64
containerfiles: |
./Containerfile
- name: Echo Outputs
run: |
echo "Image: ${{ steps.build_image.outputs.image }}"
echo "Tags: ${{ steps.build_image.outputs.tags }}"
echo "Tagged Image: ${{ steps.build_image.outputs.image-with-tag }}"
- name: Check images created
run: buildah images | grep '${{ env.IMAGE_NAME }}'

- name: Check manifest
run: |
set -x
buildah manifest inspect ${{ steps.build_image.outputs.image }}:${{ env.IMAGE_TAG }}
- name: Push To ghcr.io
id: push-to-ghcr
if: ${{ github.event_name != 'pull_request' }}
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build_image.outputs.image }}
tags: ${{ steps.build_image.outputs.tags }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Print image url
if: ${{ github.event_name != 'pull_request' }}
run: echo "Image pushed to ${{ steps.push-to-ghcr.outputs.registry-paths }}"

dependency-submission:

Expand Down

0 comments on commit 1c00791

Please sign in to comment.