Skip to content

chore: Move publishing artifacts jobs to pull-request-check.yaml work… #415

chore: Move publishing artifacts jobs to pull-request-check.yaml work…

chore: Move publishing artifacts jobs to pull-request-check.yaml work… #415

#
# Copyright (c) 2021 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: Pull Request Check
# Trigger the workflow on pull request
on: [pull_request]
env:
PR_NUMBER: ${{ github.event.number }}
jobs:
build:
name: build
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
dist: ['libc-ubi8', 'libc-ubi9', 'musl']
arch: ['amd64']
steps:
- name: Checkout che-code source code
uses: actions/checkout@v4
- name: Cleanup docker images
run: |
docker system prune -af
- 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: Display docker images
run: |
docker images
- name: Compress image to a file
run: |
docker save linux-${{matrix.dist}}-${{matrix.arch}} | gzip > linux-${{matrix.dist}}-${{matrix.arch}}.tgz
- name: Upload image artifact
uses: actions/upload-artifact@v4
with:
name: linux-${{matrix.dist}}-${{matrix.arch}}
path: linux-${{matrix.dist}}-${{matrix.arch}}.tgz
assemble:
name: assemble
runs-on: ubuntu-22.04
needs: build
steps:
- name: Checkout che-code source code
uses: actions/checkout@v4
- name: Cleanup docker images
run: |
docker system prune -af
- name: Download editor artifacts
uses: actions/download-artifact@v4
with:
pattern: linux-*
merge-multiple: true
path: .
- name: List downloaded files
run: |
ls -lah
- name: Load docker images
run: |
docker load -i linux-libc-ubi8-amd64.tgz
docker load -i linux-libc-ubi9-amd64.tgz
docker load -i linux-musl-amd64.tgz
- name: Display docker images
run: |
docker images
- name: Assemble che-code
run: |
docker buildx build \
--platform linux/amd64 \
--progress=plain \
-f build/dockerfiles/assembly.Dockerfile \
-t che-code .
- name: Display docker images
run: |
docker images
- name: Compress image to a file
run: |
docker save che-code | gzip > che-code.tgz
- name: Upload image artifact
uses: actions/upload-artifact@v4
with:
name: che-code
path: che-code.tgz
dev:
name: build-che-dev-image
runs-on: ubuntu-22.04
steps:
- name: Checkout che-code source code
uses: actions/checkout@v4
- name: Cleanup docker images
run: |
docker system prune -af
- name: Build Che-Code Docker image
run: |
docker buildx build \
--platform linux/amd64 \
--progress=plain \
-f build/dockerfiles/dev.Dockerfile \
-t che-dev .
- name: Display docker images
run: |
docker images
- name: Compress che-dev image to a file
run: |
docker save che-dev | gzip > che-dev.tgz
- name: Upload che-dev docker image artifact
uses: actions/upload-artifact@v4
with:
name: che-dev
path: che-dev.tgz
publish-images:
name: publish image from the pull request
runs-on: ubuntu-22.04
needs: [assemble, dev]
steps:
- name: Checkout che-code source code
uses: actions/checkout@v4
- name: Cleanup docker images
run: |
docker system prune -af
- name: Download che-code docker image artifact
uses: actions/download-artifact@v4
with:
pattern: che-*
merge-multiple: true
path: .
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ github.token }}
- name: List downloaded files
run: |
ls -lahR
- name: Load Docker images
run: |
docker load -i che-code.tgz
docker load -i che-dev.tgz
- name: Login to Quay.io
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_PULL_REQUESTS_USERNAME }}
password: ${{ secrets.QUAY_PULL_REQUESTS_PASSWORD }}
- name: Push che-code docker image
run: |
export IMAGE=quay.io/che-incubator-pull-requests/che-code:pr-${{env.PR_NUMBER}}-amd64
docker tag che-code ${IMAGE}
docker push ${IMAGE}
echo "_CHE_CODE_IMAGE=${IMAGE}" >> $GITHUB_ENV
- name: Push che-dev docker image
run: |
export IMAGE=quay.io/che-incubator-pull-requests/che-code-dev:pr-${{env.PR_NUMBER}}-dev-amd64
docker tag che-dev ${IMAGE}
docker push ${IMAGE}
echo "_CHE_DEV_IMAGE=${IMAGE}" >> $GITHUB_ENV
- name: 'Comment PR'
uses: actions/github-script@v7
with:
script: |
const { repo: { owner, repo } } = context;
await github.rest.issues.createComment({
issue_number: process.env.PR_NUMBER,
owner: context.repo.owner,
repo: context.repo.repo,
body: `Pull Request images published ✨\n\nEditor: [${process.env._CHE_CODE_IMAGE}](https://${process.env._CHE_CODE_IMAGE})\nDev image: [${process.env._CHE_DEV_IMAGE}](https://${process.env._CHE_DEV_IMAGE})`
})