-
Notifications
You must be signed in to change notification settings - Fork 35
160 lines (133 loc) · 4.65 KB
/
pr-check-build-che-code-image.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#
# Copyright (c) 2023-2024 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
#
name: Pull Request Check
# Trigger the workflow on pull request
on: [pull_request]
jobs:
build:
name: build
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
dist: [ 'musl', 'libc-ubi8', 'libc-ubi9' ]
arch: ['amd64']
steps:
- name: Checkout che-code source code
uses: actions/checkout@v3
- name: Compile che-code
run: |
docker buildx build \
--platform linux/${{matrix.arch}} \
--progress=plain \
-f build/dockerfiles/linux-${{matrix.dist}}.Dockerfile \
-t linux-${{matrix.dist}}-${{matrix.arch}} .
- name: Upload image
uses: ishworkh/docker-image-artifact-upload@v1
with:
image: "linux-${{matrix.dist}}-${{matrix.arch}}"
assemble:
name: assemble
runs-on: ubuntu-22.04
needs: build
steps:
- name: Checkout che-code source code
uses: actions/checkout@v3
- name: Cleanup docker images
run: |
docker system prune -af
- name: Download linux-libc-ubi8-amd64 image
uses: ishworkh/docker-image-artifact-download@v1
with:
image: "linux-libc-ubi8-amd64"
- name: Download linux-libc-ubi9-amd64 image
uses: ishworkh/docker-image-artifact-download@v1
with:
image: "linux-libc-ubi9-amd64"
- name: Download linux-musl-amd64 image
uses: ishworkh/docker-image-artifact-download@v1
with:
image: "linux-musl-amd64"
- name: Login to Quay.io
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_PULL_REQUESTS_USERNAME }}
password: ${{ secrets.QUAY_PULL_REQUESTS_PASSWORD }}
- name: Display docker images
run: |
docker images
- name: Assemble che-code
run: |
PR_NUMBER="${{ github.event.number }}"
echo "Pull request $PR_NUMBER"
IMAGE_NAME="quay.io/che-incubator-pull-requests/che-code:pr-$PR_NUMBER-amd64"
echo "_IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV
docker buildx build \
--platform linux/amd64 \
--progress=plain \
--push \
-f build/dockerfiles/assembly.Dockerfile \
-t ${IMAGE_NAME} .
- name: Display docker images (final)
run: |
docker images
- name: 'Comment PR'
uses: actions/github-script@v6
with:
script: |
const { repo: { owner, repo } } = context;
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `Pull Request Che-Code image published:\n👉 [${process.env._IMAGE_NAME}](https://${process.env._IMAGE_NAME})`
})
dev:
name: dev
runs-on: ubuntu-22.04
steps:
- name: Checkout che-code source code
uses: actions/checkout@v2
- name: Login to Quay.io
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_PULL_REQUESTS_USERNAME }}
password: ${{ secrets.QUAY_PULL_REQUESTS_PASSWORD }}
- name: Build Che-Code Docker image
run: |
PR_NUMBER="${{ github.event.number }}"
echo "Pull request $PR_NUMBER"
DEV_IMAGE_NAME="quay.io/che-incubator-pull-requests/che-code-dev:pr-$PR_NUMBER-dev-amd64"
echo "Dev image $DEV_IMAGE_NAME"
echo "_DEV_IMAGE_NAME=${DEV_IMAGE_NAME}" >> $GITHUB_ENV
docker buildx build \
--platform linux/amd64 \
--progress=plain \
--push \
-f build/dockerfiles/dev.Dockerfile \
-t ${DEV_IMAGE_NAME} .
- name: Display docker images
run: |
docker images
- name: 'Comment PR'
uses: actions/github-script@v6
with:
script: |
const { repo: { owner, repo } } = context;
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `Pull Request Dev image published:\n👉 [${process.env._DEV_IMAGE_NAME}](https://${process.env._DEV_IMAGE_NAME})`
})