Skip to content

Commit

Permalink
ci(push): add config for CI build and publish on push (backport #147) (
Browse files Browse the repository at this point in the history
…#148)

* ci(push): add config for CI build and publish on push (#147)

(cherry picked from commit b57640d)

* ci(push): fix container stream name (#149) (#150)

(cherry picked from commit 9bd6ee6)

# Conflicts:
#	.github/workflows/push-ci.yaml

Co-authored-by: Andrew Azores <aazores@redhat.com>

Co-authored-by: Andrew Azores <aazores@redhat.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
mergify[bot] and andrewazores authored Nov 15, 2022
1 parent 46a0201 commit a284e55
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 9 deletions.
10 changes: 1 addition & 9 deletions .github/workflows/ci.yaml → .github/workflows/pr-ci.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
name: CI build
name: PR CI build

on:
push:
branches:
- main
- v[0-9]+
- v[0-9]+.[0-9]+
- cryostat-v[0-9]+.[0-9]+
pull_request:
branches:
- main
Expand All @@ -16,9 +10,7 @@ on:

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
Expand Down
76 changes: 76 additions & 0 deletions .github/workflows/push-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
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:21.3-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' }}
22 changes: 22 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
</quarkus.native.additional-build-args>
<com.diffplug.spotless.maven.plugin.version>2.22.7</com.diffplug.spotless.maven.plugin.version>
<com.mycila.license.maven.plugin.version>4.0</com.mycila.license.maven.plugin.version>
<org.codehaus.mojo.build.helper.plugin.version>3.3.0</org.codehaus.mojo.build.helper.plugin.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -275,6 +276,27 @@
</licenseSets>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>${org.codehaus.mojo.build.helper.plugin.version}</version>
<executions>
<execution>
<id>image-tag-to-lower</id>
<goals>
<goal>regex-property</goal>
</goals>
<configuration>
<name>imageVersionLower</name>
<regex>^.*$</regex>
<value>${project.version}</value>
<replacement>${project.version}</replacement>
<toLowerCase>true</toLowerCase>
<failIfNoMatch>false</failIfNoMatch>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

0 comments on commit a284e55

Please sign in to comment.