-
Notifications
You must be signed in to change notification settings - Fork 13
76 lines (73 loc) · 3 KB
/
push-ci.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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-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' }}