Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

Commit

Permalink
Adds buildx in GitHub Action job
Browse files Browse the repository at this point in the history
Signed-off-by: Prabhav Thali <Prabhav.Thali1@ibm.com>
  • Loading branch information
prabhav-thali committed Jan 6, 2021
1 parent 117efdd commit 5b5f74c
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 49 deletions.
31 changes: 23 additions & 8 deletions .github/workflows/nightly-build-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,23 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone source code
uses: actions/checkout@v1
uses: actions/checkout@v2
with:
fetch-depth: 1

- name: Prepare
id: prep
run: |
SHORT_SHA1=$(git rev-parse --short HEAD)
echo ::set-output name=short_sha1::${SHORT_SHA1}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Login to quay.io
uses: docker/login-action@v1
with:
Expand All @@ -37,10 +50,12 @@ jobs:
run: /bin/bash arbitrary-users-patch/happy-path/build_happy_path_image.sh --push

- name: Build and push devfile image
run: |
SHORT_SHA1=$(git rev-parse --short HEAD)
docker build -t che-devfile-registry -f ./build/dockerfiles/Dockerfile --target registry .
docker tag che-devfile-registry quay.io/eclipse/che-devfile-registry:nightly
docker push quay.io/eclipse/che-devfile-registry:nightly
docker tag che-devfile-registry quay.io/eclipse/che-devfile-registry:${SHORT_SHA1}
docker push quay.io/eclipse/che-devfile-registry:${SHORT_SHA1}
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
file: ./build/dockerfiles/Dockerfile
target: registry
platforms: linux/amd64,linux/s390x
tags: quay.io/eclipse/che-devfile-registry:nightly,quay.io/eclipse/che-devfile-registry:${{ steps.prep.outputs.short_sha1 }}
push: true
69 changes: 39 additions & 30 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
shellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2

- name: Shellcheck
run: |
Expand All @@ -28,7 +28,9 @@ jobs:
digest-validation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Run script which checks container image digest
run: |
sudo pip install yq
Expand All @@ -39,38 +41,45 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: 'Checkout Source Code'
uses: actions/checkout@v2

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Cache docker layers
uses: actions/cache@v1
uses: actions/cache@v2
id: cache
with:
path: ./caches
key: v1-${{ github.head_ref }}

- name: Load docker layer cache
run: |
set +o pipefail
docker load -i ./caches/app.tar | true
path: /tmp/.buildx-cache
key: v2-${{ github.head_ref }}

- name: 'Docker Prepare'
run: docker image prune -a -f

- name: Build devfile registry
run: |
docker build \
--cache-from=app \
-t app \
-f ./build/dockerfiles/Dockerfile \
--target registry .
- name: Cache docker layers
run: |
mkdir -p ./caches
docker save -o ./caches/app.tar app
uses: docker/build-push-action@v2
with:
context: .
file: ./build/dockerfiles/Dockerfile
target: registry
platforms: linux/amd64,linux/s390x
tags: app
cache-from: "type=local,src=/tmp/.buildx-cache"
cache-to: "type=local,dest=/tmp/.buildx-cache"
push: false

- name: Build offline devfile registry
run: |
docker build \
--cache-from=app \
-t app \
-f ./build/dockerfiles/Dockerfile \
--target offline-registry .

uses: docker/build-push-action@v2
with:
context: .
file: ./build/dockerfiles/Dockerfile
target: offline-registry
platforms: linux/amd64,linux/s390x
tags: app
cache-from: "type=local,src=/tmp/.buildx-cache"
push: false
41 changes: 30 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,28 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone source code
uses: actions/checkout@v1
uses: actions/checkout@v2
with:
fetch-depth: 1
ref: release

- name: Prepare
id: prep
run: |
SHORT_SHA1=$(git rev-parse --short HEAD)
echo ::set-output name=short_sha1::${SHORT_SHA1}
VERSION=$(head -n 1 VERSION)
echo ::set-output name=version::${VERSION}
IMAGE=che-devfile-registry
echo ::set-output name=image::${IMAGE}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Login to Quay.io
uses: azure/docker-login@v1
with:
Expand All @@ -46,13 +63,15 @@ jobs:
/bin/bash arbitrary-users-patch/build_images.sh --push
- name: Build and push images
run: |
SHORT_SHA1=$(git rev-parse --short HEAD)
VERSION=$(head -n 1 VERSION)
IMAGE=che-devfile-registry
DOCKERFILE_PATH=./build/dockerfiles/Dockerfile
docker build -t ${IMAGE} -f ${DOCKERFILE_PATH} --build-arg PATCHED_IMAGES_TAG=${VERSION} --target registry .
docker tag ${IMAGE} quay.io/eclipse/${IMAGE}:${SHORT_SHA1}
docker push quay.io/eclipse/${IMAGE}:${SHORT_SHA1}
docker tag ${IMAGE} quay.io/eclipse/${IMAGE}:${VERSION}
docker push quay.io/eclipse/${IMAGE}:${VERSION}
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
file: ./build/dockerfiles/Dockerfile
target: registry
build-args: |
PATCHED_IMAGES_TAG=${{ steps.prep.outputs.version }}
platforms: linux/amd64,linux/s390x
tags: quay.io/eclipse/${{ steps.prep.outputs.image }}:${{ steps.prep.outputs.version }},quay.io/eclipse/${{ steps.prep.outputs.image }}:${{ steps.prep.outputs.short_sha1 }}
push: true

0 comments on commit 5b5f74c

Please sign in to comment.