forked from cryostatio/cryostat
-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (138 loc) · 4.78 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: CI build and push
concurrency:
group: ci-${{ github.run_id }}
cancel-in-progress: true
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 1' # every Monday at midnight
push:
branches:
- main
- v[0-9]+
- 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/cryostat
jobs:
get-pom-properties:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- id: query-pom
name: Get properties from POM
# Query POM image version and save as output parameter
run: |
IMAGE_VERSION="$(mvn -q -DforceStdout validate help:evaluate -Dexpression=quarkus.application.version)"
echo "::set-output name=image-version::$IMAGE_VERSION"
outputs:
image-version: ${{ steps.query-pom.outputs.image-version }}
build-and-test:
# runs-on: ubuntu-latest
runs-on: ubuntu-24.04
needs: [get-pom-properties]
strategy:
matrix:
arch: [amd64, arm64]
env:
IMAGE_VERSION: ${{ needs.get-pom-properties.outputs.image-version }}
frontend-cache-name: cache-yarn
name: Build and test
permissions:
packages: write
contents: read
if: ${{ github.repository_owner == 'cryostatio' }}
steps:
- name: Install podman 4 and qemu
run: |
sudo apt update
sudo apt -y satisfy "podman (>= 4.0), qemu-user-static"
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
- run: git submodule init && git submodule update
- name: Cache yarn packages and frontend build
uses: actions/cache@v4
with:
path: |
./src/main/webui/.yarn/cache
./src/main/webui/.yarn/install-state.gz
./src/main/webui/node_modules
./src/main/webui/.build_cache
key: ${{ runner.os }}-build-${{ env.frontend-cache-name }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.frontend-cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Initialize web assets
run: |
pushd src/main/webui
yarn install && yarn yarn:frzinstall
popd
- name: Build ${{ matrix.arch }} container image
id: build-image
run: |
./mvnw -B -U \
-Dquarkus.container-image.image=${{ env.CI_IMG }}:linux-${{ matrix.arch }} \
-Dquarkus.docker.executable-name=docker \
-Dquarkus.docker.buildx.platform=linux/${{ matrix.arch }} \
-Dbuild.arch=${{ matrix.arch }} \
clean verify
- name: Copy docker image to podman
run: podman pull docker-daemon:${{ env.CI_IMG }}:linux-${{ matrix.arch }}
- name: Save container image
run: podman save -o cryostat-${{ matrix.arch }}.tar --format oci-archive ${{ env.CI_IMG }}:linux-${{ matrix.arch }}
- uses: actions/upload-artifact@v4
with:
name: cryostat-${{ matrix.arch }}
path: cryostat-${{ matrix.arch }}.tar
publish-manifest:
runs-on: ubuntu-latest
needs: [get-pom-properties, build-and-test]
steps:
- name: Download container tarballs
uses: actions/download-artifact@v4
with:
path: containers
pattern: cryostat-*
merge-multiple: true
- name: Create manifest
run: podman manifest create ${{ env.CI_IMG }}:${{ needs.get-pom-properties.outputs.image-version }}
- name: Set manifest tags
id: manifest-tags
run: |
TAGS=(${{ needs.get-pom-properties.outputs.image-version }})
if [ '${{ github.ref }}' == 'refs/heads/main' ]; then
podman tag ${{ env.CI_IMG }}:${{ needs.get-pom-properties.outputs.image-version }} ${{ env.CI_IMG }}:latest
TAGS+=(latest)
fi
echo "::set-output name=tags::${TAGS[@]}"
- name: Import container tarballs
run: |
find containers -type f -exec podman load -i {} \;
for tag in $(podman images --filter label=io.cryostat.component --format '{{ .Tag }}'); do
podman manifest add ${{ env.CI_IMG }}:${{ needs.get-pom-properties.outputs.image-version }} containers-storage:${{env.CI_IMG}}:${tag}
done
- name: Push to quay.io
if: github.repository_owner == 'cryostatio'
id: push-to-quay
uses: redhat-actions/push-to-registry@v2
with:
image: cryostat
tags: ${{ steps.manifest-tags.outputs.tags }}
registry: ${{ env.CI_REGISTRY }}
username: ${{ env.CI_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Print image URL
run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}"