This repository has been archived by the owner on Jan 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
104 lines (100 loc) · 3.87 KB
/
build-publish.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
#
# Copyright (c) 2020 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
#
name: Build and push container
on:
push:
branches:
- 'master'
env:
IMAGE_NAME: quay.io/eclipse/che-custom-nodejs-deasync
CACHE_IMAGE_NAME: chedockerfiles/custom-nodejs-deasync-cache
jobs:
pre-compiler:
strategy:
matrix:
platform: ['linux/amd64', 'linux/arm64', 'linux/ppc64le']
runs-on: ubuntu-latest
steps:
- name: Clone source code
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Docker login
run: |
docker login -u ${{ secrets.CACHE_USERNAME }} -p ${{ secrets.CACHE_PASSWORD }}
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} quay.io
- name: Docker Buildx
uses: crazy-max/[email protected]
with:
buildx-version: v0.4.2
qemu-version: 5.1.0-2
- name: Docker build, tag, and push
run: |
IMAGE_VERSION=$(cat VERSION)
PLATFORM=$(echo ${{matrix.platform}} | tr '\/' '-')
IMAGE_WITH_TAG="${IMAGE_NAME}:${IMAGE_VERSION}-${PLATFORM}-precompiler"
CACHE_IMAGE_TAG="${CACHE_IMAGE_NAME}:${IMAGE_VERSION}-${PLATFORM}-precompiler-cache"
echo "Building ${IMAGE_WITH_TAG} on platform ${{matrix.platform}}"
docker buildx build --cache-from="type=registry,ref=${CACHE_IMAGE_TAG}" --cache-to="type=registry,ref=${CACHE_IMAGE_TAG},mode=max" --platform "${{matrix.platform}}" --target precompiler .
compiler:
needs: pre-compiler
strategy:
matrix:
platform: ['linux/amd64', 'linux/arm64', 'linux/ppc64le']
runs-on: ubuntu-latest
steps:
- name: Clone source code
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Docker login
run: |
docker login -u ${{ secrets.CACHE_USERNAME }} -p ${{ secrets.CACHE_PASSWORD }}
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} quay.io
- name: Docker Buildx
uses: crazy-max/[email protected]
with:
buildx-version: v0.4.2
qemu-version: 5.1.0-2
- name: Docker build, tag, and push
run: |
IMAGE_VERSION=$(cat VERSION)
PLATFORM=$(echo ${{matrix.platform}} | tr '\/' '-')
IMAGE_WITH_TAG="${IMAGE_NAME}:${IMAGE_VERSION}-${PLATFORM}"
CACHE_IMAGE_TAG="${CACHE_IMAGE_NAME}:${IMAGE_VERSION}-${PLATFORM}-precompiler-cache"
echo "Building ${IMAGE_WITH_TAG} on platform ${{matrix.platform}}"
docker buildx build --cache-from="type=registry,ref=${CACHE_IMAGE_TAG}" --platform "${{matrix.platform}}" -t "${IMAGE_WITH_TAG}" --push .
assemble:
needs: compiler
runs-on: ubuntu-latest
steps:
- name: Clone source code
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Docker login
run: |
docker login -u ${{ secrets.CACHE_USERNAME }} -p ${{ secrets.CACHE_PASSWORD }}
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} quay.io
- name: Docker Buildx
uses: crazy-max/[email protected]
with:
buildx-version: v0.4.2
qemu-version: 5.1.0-2
- name: Create multi-arch image
run: |
IMAGE_VERSION=$(cat VERSION)
IMAGE_WITH_TAG="${IMAGE_NAME}:${IMAGE_VERSION}"
echo "Creating manifest for multi-arch build "
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create ${IMAGE_WITH_TAG} \
${IMAGE_NAME}:${IMAGE_VERSION}-linux-arm64 \
${IMAGE_NAME}:${IMAGE_VERSION}-linux-ppc64le \
${IMAGE_NAME}:${IMAGE_VERSION}-linux-s390x \
${IMAGE_NAME}:${IMAGE_VERSION}-linux-amd64
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push ${IMAGE_WITH_TAG}