Skip to content

Commit

Permalink
ci(multiarch): build multiarch OCI manifest on push
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores committed Aug 17, 2023
1 parent 974d9b0 commit 2dfb4a0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 39 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/pr-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,10 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
cache: 'maven'
- run: mvn -B -U clean verify
55 changes: 24 additions & 31 deletions .github/workflows/push-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@ on:
- v[0-9]+.[0-9]+
- cryostat-v[0-9]+.[0-9]+

env:
CI_USER: cryostat+bot
CI_REGISTRY: quay.io/cryostat
CI_IMG: quay.io/cryostat/jfr-datasource

jobs:
get-pom-properties:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- id: query-pom
name: Get properties from POM
# Query POM for image version and save as output parameter
Expand All @@ -29,46 +34,34 @@ jobs:
runs-on: ubuntu-latest
needs: [get-pom-properties]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
- uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- run: mvn -Pnative -Dquarkus.native.container-build=true -Dquarkus.native.container-runtime=podman -Dquarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-mandrel-builder-image:23.0-java17 clean verify
- run: podman build -f src/main/docker/Dockerfile.native -t "quay.io/cryostat/$IMAGE_NAME:$IMAGE_VERSION" .
distribution: 'temurin'
cache: 'maven'
- name: Build application
run: mvn -B -U clean verify
- name: Build container images and manifest
id: buildah-build
uses: redhat-actions/buildah-build@v2
env:
IMAGE_NAME: ${{ needs.get-pom-properties.outputs.image-name }}
IMAGE_VERSION: ${{ needs.get-pom-properties.outputs.image-version }}
if: ${{ github.event_name == 'push' && github.repository_owner == 'cryostatio' }}
- name: Tag images
id: tag-image
env:
IMAGE_NAME: ${{ needs.get-pom-properties.outputs.image-name }}
IMAGE_VERSION: ${{ needs.get-pom-properties.outputs.image-version }}
run: |
if [ "$GITHUB_REF" == "refs/heads/main" ]; then
podman tag \
quay.io/cryostat/$IMAGE_NAME:$IMAGE_VERSION \
quay.io/cryostat/$IMAGE_NAME:latest
echo "::set-output name=tags::$IMAGE_VERSION latest"
else
echo "::set-output name=tags::$IMAGE_VERSION"
fi
with:
image: ${{ env.CI_IMG }}
archs: amd64, arm64
tags: ${{ env.IMAGE_VERSION }} ${{ github.ref == 'refs/heads/main' && 'latest' || '' }}
containerfiles: |
./src/main/docker/Dockerfile.jvm
if: ${{ github.event_name == 'push' && github.repository_owner == 'cryostatio' }}
- name: Push to quay.io
id: push-to-quay
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ needs.get-pom-properties.outputs.image-name }}
tags: ${{ steps.tag-image.outputs.tags }}
registry: quay.io/cryostat
username: cryostat+bot
tags: ${{ steps.buildah-build.outputs.tags }}
registry: ${{ env.CI_REGISTRY }}
username: ${{ env.CI_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
if: ${{ github.event_name == 'push' && github.repository_owner == 'cryostatio' }}
- name: Print image URL
Expand Down

0 comments on commit 2dfb4a0

Please sign in to comment.