-
Notifications
You must be signed in to change notification settings - Fork 47
145 lines (145 loc) · 6.29 KB
/
v2-push.yml
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
name: Build and Deploy images (on push to main or wildfly-cekit-modules's events).
on:
repository_dispatch:
types: [push-in-wf-cekit-modules]
push:
branches:
- "main"
env:
LANG: en_US.UTF-8
V2_QUAY_REPO: ${{ secrets.V2_QUAY_REPO }}
V2_QUAY_SNAPSHOT_REPO: ${{ secrets.V2_QUAY_SNAPSHOT_REPO }}
V2_QUAY_USERNAME: ${{ secrets.V2_QUAY_USERNAME }}
S2I_URI: https://api.github.com/repos/openshift/source-to-image/releases/latest
WILDFLY_S2I_BUILDER_IMAGE: wildfly-s2i
WILDFLY_S2I_RUNTIME_IMAGE: wildfly-runtime
jobs:
wfci:
name: Wildfly-s2i Image Deployment on push
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
jdk: [jdk11, jdk17, jdk21]
steps:
- id: files
if: ${{ github.event_name == 'push' }}
uses: jitterbit/get-changed-files@v1
- run: |
for changed_file in ${{ steps.files.outputs.all }}; do
if [[ "${changed_file}" =~ ^.github/.* ]] || [[ "${changed_file}" =~ ^wildfly-builder-image/.* ]] || [[ "${changed_file}" =~ ^wildfly-runtime-image/.* ]] || [[ "${changed_file}" =~ ^wildfly-modules/.* ]]; then
echo "Change detected in ${changed_file}, will deploy images."
echo "IMPACT_IMAGE=true" >> "$GITHUB_ENV"
exit 0
fi
done
echo "No change detected that would impact the images, skipping the job"
- name: Enable image deployment on dispatched event from wildfly-cekit-modules
if: ${{ github.event_name == 'repository_dispatch' }}
run: |
echo "IMPACT_IMAGE=true" >> "$GITHUB_ENV"
- uses: actions/checkout@v2
if: env.IMPACT_IMAGE == 'true'
with:
ref: main
- name: Check quay.io configuration
if: (env.V2_QUAY_USERNAME == '' || env.V2_QUAY_REPO == '' || env.V2_QUAY_SNAPSHOT_REPO == '') && env.IMPACT_IMAGE == 'true'
run: |
echo "quay.io configuration is incomplete, can't push to quay.io. To push built images to quay.io, please ensure the secrets V2_QUAY_REPO, V2_QUAY_SNAPSHOT_REPO, V2_QUAY_USERNAME and V2_QUAY_PASSWORD are created in the project."
exit 1
- name: Install qemu dependency
if: env.IMPACT_IMAGE == 'true'
run: |
sudo apt-get update
sudo apt-get install -y qemu-user-static
- name: Setup required system packages
if: env.IMPACT_IMAGE == 'true'
run: |
sudo apt-get update
sudo apt-get install krb5-multidev libkrb5-dev
- name: Verify latest ubi8-minimal
if: env.IMPACT_IMAGE == 'true'
run: |
podman pull registry.access.redhat.com/ubi8/ubi-minimal
podman image ls | grep ubi8
- name: Setup virtualenv and install cekit and required packages
if: env.IMPACT_IMAGE == 'true'
run: |
sudo pip install virtualenv
mkdir ~/cekit
virtualenv ~/cekit
. ~/cekit/bin/activate
pip install cekit docker==5.0.3 docker-squash odcs behave lxml packaging==21.3
- name: Build DockerFile files
if: env.IMPACT_IMAGE == 'true'
run: |
echo "Docker Images prior to build wildfly-s2i images"
podman image ls
. ~/cekit/bin/activate
pushd wildfly-builder-image
WILDFLY_IMAGE_VERSION=$(yq e ".version" ${{ matrix.jdk }}-overrides.yaml)
if [[ "${WILDFLY_IMAGE_VERSION}" =~ .*-snapshot ]]; then
ORGANIZATION=${{ secrets.V2_QUAY_SNAPSHOT_REPO }}
QUAY_IMAGE_VERSION=${WILDFLY_IMAGE_VERSION%-snapshot}
else
ORGANIZATION=${{ secrets.V2_QUAY_REPO }}
RELEASED_IMAGES="true"
QUAY_IMAGE_VERSION="${WILDFLY_IMAGE_VERSION}"
fi
# Compute tags common to all images
WILDFLY_IMAGE_TAGS="latest-${{ matrix.jdk }} ${QUAY_IMAGE_VERSION}"
echo "WILDFLY_IMAGE_TAGS=${WILDFLY_IMAGE_TAGS}" >> $GITHUB_ENV
echo "ORGANIZATION=${ORGANIZATION}" >> $GITHUB_ENV
echo "QUAY_IMAGE_VERSION=${QUAY_IMAGE_VERSION}" >> $GITHUB_ENV
cekit build --dry-run --overrides=${{ matrix.jdk }}-overrides.yaml docker
popd
pushd wildfly-runtime-image
cekit build --dry-run --overrides=${{ matrix.jdk }}-overrides.yaml docker
popd
- name: Add latest image tag, currently JDK21
if: env.IMPACT_IMAGE == 'true' && matrix.jdk == 'jdk21'
run: |
echo "WILDFLY_IMAGE_TAGS=latest ${{ env.WILDFLY_IMAGE_TAGS }}" >> $GITHUB_ENV
- name: Buildah multi archs Builder Build
if: env.IMPACT_IMAGE == 'true'
id: build_builder_image
uses: redhat-actions/[email protected]
with:
image: ${{ env.WILDFLY_S2I_BUILDER_IMAGE }}
tags: ${{ env.WILDFLY_IMAGE_TAGS }}
context: ./wildfly-builder-image/target/image
platforms: linux/amd64, linux/arm64
containerfiles: |
./wildfly-builder-image/target/image/Dockerfile
- name: Buildah multi archs Runtime Build
if: env.IMPACT_IMAGE == 'true'
id: build_runtime_image
uses: redhat-actions/[email protected]
with:
image: ${{ env.WILDFLY_S2I_RUNTIME_IMAGE }}
tags: ${{ env.WILDFLY_IMAGE_TAGS }}
context: ./wildfly-runtime-image/target/image
platforms: linux/amd64, linux/arm64
containerfiles: |
./wildfly-runtime-image/target/image/Dockerfile
- name: Push Builder Image To Quay
if: env.IMPACT_IMAGE == 'true'
uses: redhat-actions/[email protected]
id: push-builder
with:
image: ${{ steps.build_builder_image.outputs.image }}
tags: ${{ steps.build_builder_image.outputs.tags }}
registry: quay.io/${{ env.ORGANIZATION }}
username: ${{ secrets.V2_QUAY_USERNAME }}
password: ${{ secrets.V2_QUAY_PASSWORD }}
- name: Push Runtime Image To Quay
if: env.IMPACT_IMAGE == 'true'
uses: redhat-actions/[email protected]
id: push-runtime
with:
image: ${{ steps.build_runtime_image.outputs.image }}
tags: ${{ steps.build_runtime_image.outputs.tags }}
registry: quay.io/${{ env.ORGANIZATION }}
username: ${{ secrets.V2_QUAY_USERNAME }}
password: ${{ secrets.V2_QUAY_PASSWORD }}