-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: revert back PR-ceck actions to build images (#296)
Signed-off-by: vitaliy-guliy <vgulyy@redhat.com>
- Loading branch information
1 parent
8ee6e5b
commit f6d8b8e
Showing
3 changed files
with
203 additions
and
155 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# | ||
# 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: Publish Image PR check | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["Pull Request Check"] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
publish-image-pull-request: | ||
name: publish image from the pull request | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: PR number | ||
uses: dawidd6/action-download-artifact@v2 | ||
with: | ||
workflow: ${{ github.event.workflow_run.workflow_id }} | ||
name: pull-request-number | ||
- name: Grab pull request number | ||
run: | | ||
pr_number=$(cat "PR_NUMBER") | ||
if ! [[ "$pr_number" =~ ^[0-9]+$ ]]; then | ||
echo "pr number invalid" | ||
exit 1 | ||
fi | ||
echo "PR_NUMBER=$pr_number" >> $GITHUB_ENV | ||
- name: PR sha | ||
uses: dawidd6/action-download-artifact@v2 | ||
with: | ||
workflow: ${{ github.event.workflow_run.workflow_id }} | ||
name: pull-request-sha | ||
- name: Grab pull request sha1 | ||
run: | | ||
pr_sha=$(cat "PR_SHA") | ||
echo "PR_SHA=$pr_sha" >> $GITHUB_ENV | ||
- 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: Increase Swap Space # implemented for the Linux system only | ||
if: runner.os == 'Linux' | ||
shell: bash | ||
run: | | ||
echo "Current swap area:" | ||
sudo swapon --show | ||
export SWAP_SIZE=7 | ||
export SWAP_FILE_PATH=$(swapon --show=NAME | tail -n 1) | ||
sudo swapoff $SWAP_FILE_PATH | ||
sudo rm $SWAP_FILE_PATH | ||
sudo fallocate -l ${SWAP_SIZE}G $SWAP_FILE_PATH | ||
sudo chmod 600 $SWAP_FILE_PATH | ||
sudo mkswap $SWAP_FILE_PATH | ||
sudo swapon $SWAP_FILE_PATH | ||
echo "Updated swap area:" | ||
sudo swapon --show | ||
- name: Download assembly image | ||
uses: dawidd6/action-download-artifact@v2 | ||
with: | ||
workflow: ${{ github.event.workflow_run.workflow_id }} | ||
name: action_image_artifact_assembly-pr | ||
path: assembly-image/ | ||
- name: Load docker image | ||
run: | | ||
ls -la assembly-image/ | ||
docker load -i assembly-image/assembly-pr | ||
- name: Docker Push | ||
run: | | ||
export IMAGE_NAME=quay.io/che-incubator-pull-requests/che-code:pr-${{env.PR_NUMBER}}-amd64 | ||
docker tag assembly-pr ${IMAGE_NAME} | ||
docker push ${IMAGE_NAME} | ||
echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV | ||
- name: Download dev image | ||
uses: dawidd6/action-download-artifact@v2 | ||
with: | ||
workflow: ${{ github.event.workflow_run.workflow_id }} | ||
name: dev-image | ||
- name: Load dev Docker image | ||
run: | | ||
docker load -i dev-pr.tgz | ||
- name: Docker Push | ||
run: | | ||
export DEV_IMAGE_NAME=quay.io/che-incubator-pull-requests/che-code-dev:pr-${{env.PR_NUMBER}}-dev-amd64 | ||
docker tag dev-pr ${DEV_IMAGE_NAME} | ||
docker push ${DEV_IMAGE_NAME} | ||
echo "DEV_IMAGE_NAME=${DEV_IMAGE_NAME}" >> $GITHUB_ENV | ||
- name: 'Comment PR' | ||
uses: actions/github-script@v6 | ||
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 ✨\nimage: ${process.env.IMAGE_NAME}\n Dev image: ${process.env.DEV_IMAGE_NAME}` | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# | ||
# 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] | ||
|
||
jobs: | ||
|
||
build: | ||
name: build | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
dist: [ 'musl', 'libc' ] | ||
arch: ['amd64'] | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Docker Build | ||
env: | ||
# https://github.com/microsoft/vscode-ripgrep#github-api-limit-note | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
docker buildx build --memory-swap -1 --memory 10g --platform linux/${{matrix.arch}} -f build/dockerfiles/linux-${{matrix.dist}}.Dockerfile --load -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 | ||
needs: build | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Download linux-libc-amd64 image | ||
uses: ishworkh/docker-image-artifact-download@v1 | ||
with: | ||
image: "linux-libc-amd64" | ||
- name: Download linux-musl image | ||
uses: ishworkh/docker-image-artifact-download@v1 | ||
with: | ||
image: "linux-musl-amd64" | ||
- name: Display docker images | ||
run: | | ||
docker images | ||
- name: Docker Build | ||
run: | | ||
docker buildx build --platform linux/amd64 -f build/dockerfiles/assembly.Dockerfile --load -t assembly-pr . | ||
- name: Upload assembly image | ||
uses: ishworkh/docker-image-artifact-upload@v1 | ||
with: | ||
image: "assembly-pr" | ||
- name: Store PR info | ||
run: | | ||
echo "${{ github.event.number }}" > PR_NUMBER | ||
echo "${{ github.event.pull_request.head.sha }}" > PR_SHA | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: pull-request-number | ||
path: PR_NUMBER | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: pull-request-sha | ||
path: PR_SHA | ||
dev: | ||
name: dev | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Docker Build | ||
run: | | ||
docker buildx build --platform linux/amd64 -f build/dockerfiles/dev.Dockerfile --load -t dev-pr . | ||
docker save dev-pr | gzip > dev-pr.tgz | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: dev-image | ||
path: dev-pr.tgz |