forked from cryostatio/cryostat-openshift-console-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
159 lines (151 loc) · 4.63 KB
/
ci.yaml
File metadata and controls
159 lines (151 loc) · 4.63 KB
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: Container Build
on:
workflow_call:
inputs:
push-container:
required: false
type: boolean
default: false
additional-tags:
required: false
type: string
default: ''
env:
CI_USER: cryostat+bot
CI_REGISTRY: quay.io/cryostat
CI_IMG: quay.io/cryostat/cryostat-openshift-console-plugin
IMG_NAME: cryostat-openshift-console-plugin
jobs:
format-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 'lts/*'
cache: 'yarn'
- uses: bahmutov/npm-install@v1
- run: yarn format
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 'lts/*'
cache: 'yarn'
- uses: bahmutov/npm-install@v1
- run: yarn lint
type-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 'lts/*'
cache: 'yarn'
- uses: bahmutov/npm-install@v1
- run: yarn type-check:plugin
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ['lts/*']
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- uses: bahmutov/npm-install@v1
- run: yarn test:ci
build-container:
strategy:
matrix:
arch: [amd64, arm64]
runs-on: ${{ matrix.arch == 'amd64' && 'ubuntu-24.04' || 'ubuntu-24.04-arm' }}
if: ${{ github.repository_owner == 'cryostatio' }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: Install buildah and podman
run: |
sudo apt -y update
sudo apt -y install buildah podman
- name: Build container
id: container-build
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.CI_IMG }}
oci: true
tags: ${{ github.sha }}-${{ matrix.arch }}
archs: ${{ matrix.arch }}
containerfiles: |
./Dockerfile
extra-args: |
--jobs=2
- name: Save container image
run: podman save -o ${{ github.sha }}-${{ matrix.arch }}.tar --format oci-archive ${{ env.CI_IMG }}:${{ github.sha }}-${{ matrix.arch }}
- uses: actions/upload-artifact@v4
with:
name: ${{ github.sha }}-${{ matrix.arch }}
path: ${{ github.sha }}-${{ matrix.arch }}.tar
publish-manifest:
runs-on: ubuntu-latest
needs: [build-container]
if: ${{ github.repository_owner == 'cryostatio' && inputs.push-container}}
steps:
- name: Download container tarballs
uses: actions/download-artifact@v4
with:
path: containers
pattern: ${{ github.sha }}-*
merge-multiple: true
- name: Create manifest
run: podman manifest create ${{ env.CI_IMG }}:${{ github.sha }}
- name: Import container tarballs to manifest
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 }}:${{ github.sha }} containers-storage:${{ env.CI_IMG }}:${tag}
done
- name: Set manifest tags
id: manifest-tags
run: |
TAGS=()
if [ '${{ github.ref }}' == 'refs/heads/main' ]; then
TAGS+=("latest")
fi
for tag in ${{ inputs.additional-tags }}; do
TAGS+=("${tag}")
done
echo "::set-output name=tags::${TAGS[@]}"
- name: Tag manifest
run: |
for tag in ${{ steps.manifest-tags.outputs.tags }}; do
podman tag ${{ env.CI_IMG }}:${{ github.sha }} ${{ env.CI_IMG }}:${tag}
done
- name: Push to registry
id: push-to-registry
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ env.IMG_NAME }}
tags: ${{ github.ref == 'refs/heads/main' && 'latest' || '' }} ${{ inputs.additional-tags }}
registry: ${{ env.CI_REGISTRY }}
username: ${{ env.CI_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}