chore(build): JVM-mode Dockerfile (#203) #43
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI build and publish | |
on: | |
push: | |
branches: | |
- main | |
- v[0-9]+ | |
- v[0-9]+.[0-9]+ | |
- cryostat-v[0-9]+.[0-9]+ | |
jobs: | |
get-pom-properties: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- id: query-pom | |
name: Get properties from POM | |
# Query POM for image version and save as output parameter | |
run: | | |
IMAGE_NAME="$(mvn validate help:evaluate -Dexpression=project.artifactId -q -DforceStdout)" | |
echo "::set-output name=image-name::$IMAGE_NAME" | |
IMAGE_VERSION="$(mvn validate help:evaluate -Dexpression=imageVersionLower -q -DforceStdout)" | |
echo "::set-output name=image-version::$IMAGE_VERSION" | |
outputs: | |
image-name: ${{ steps.query-pom.outputs.image-name }} | |
image-version: ${{ steps.query-pom.outputs.image-version }} | |
build: | |
runs-on: ubuntu-latest | |
needs: [get-pom-properties] | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-java@v2 | |
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" . | |
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 | |
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 | |
password: ${{ secrets.REGISTRY_PASSWORD }} | |
if: ${{ github.event_name == 'push' && github.repository_owner == 'cryostatio' }} | |
- name: Print image URL | |
run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}" | |
if: ${{ github.event_name == 'push' && github.repository_owner == 'cryostatio' }} |