Skip to content

Commit

Permalink
feat: ci-hub-support
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Riobo <[email protected]>
  • Loading branch information
adrianriobo committed Oct 2, 2024
1 parent 7906192 commit ed2e79f
Show file tree
Hide file tree
Showing 6 changed files with 157 additions and 45 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/ci-hub-support-builder.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: ci-hub-support-builder

on:
push:
tags: [ 'ci-hub-support-v*' ]
pull_request:
branches: [ main ]
paths: ['ci-hub-support/**', '.github\/workflows\/ci-hub-support*' ]

jobs:
build:
name: build
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Build image for PR
if: ${{ github.event_name == 'pull_request' }}
env:
CI_HUB_SUPPORT: ghcr.io/devtools-qe-incubator/ci-hub-support
CI_HUB_SUPPORT_V: pr-${{ github.event.number }}
run: |
make ci-hub-support-oci-build
make ci-hub-support-oci-save
echo "image=${CI_HUB_SUPPORT}:${CI_HUB_SUPPORT_V}" >> "$GITHUB_ENV"
- name: Build image for Release
if: ${{ github.event_name == 'push' }}
run: |
make ci-hub-support-oci-build
make ci-hub-support-oci-save
echo "image=$(sed -n 1p ci-hub-support/release-info):v$(sed -n 2p ci-hub-support/release-info)" >> "$GITHUB_ENV"
- name: Create image metadata
run: |
echo ${{ env.image }} > ci-hub-support-image
echo ${{ github.event_name }} > ci-hub-support-build-event
- name: Upload ci-hub-support
uses: actions/upload-artifact@v4
with:
name: ci-hub-support
path: ci-hub-support*









51 changes: 51 additions & 0 deletions .github/workflows/ci-hub-support-pusher.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: ci-hub-support-pusher

on:
workflow_run:
workflows:
- ci-hub-support-builder
types:
- completed

jobs:
push:
name: push
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
steps:
- name: Download ci-hub-support assets
uses: actions/download-artifact@v4
with:
name: ci-hub-support
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ github.token }}

- name: Get ci-hub-support build informaiton
run: |
echo "source_event=$(cat ci-hub-support-build-event)" >> "$GITHUB_ENV"
echo "image=$(cat ci-hub-support-image)" >> "$GITHUB_ENV"
- name: Log in to ghcr.io
if: ${{ env.source_event == 'pull_request' }}
uses: redhat-actions/podman-login@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Log in quay.io
if: ${{ env.source_event == 'push' }}
uses: redhat-actions/podman-login@v1
with:
registry: quay.io
username: ${{ secrets.QUAY_IO_USERNAME }}
password: ${{ secrets.QUAY_IO_PASSWORD }}

- name: Push ci-hub-support
run: |
podman load -i ci-hub-support.tar
podman push ${{ env.image }}
30 changes: 30 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
CONTAINER_MANAGER ?= podman

#### ci-hub-support ####

.PHONY: ci-hub-support-oci-build ci-hub-support-oci-save ci-hub-support-oci-load ci-hub-support-oci-push

# Variables
CI_HUB_SUPPORT ?= $(shell sed -n 1p ci-hub-support/release-info)
CI_HUB_SUPPORT_V ?= v$(shell sed -n 2p ci-hub-support/release-info)
CI_HUB_SUPPORT_SAVE ?= ci-hub-support

ci-hub-support-oci-build: CONTEXT=ci-hub-support
ci-hub-support-oci-build: MANIFEST=$(CI_HUB_SUPPORT):$(CI_HUB_SUPPORT_V)
ci-hub-support-oci-build:
${CONTAINER_MANAGER} build -t $(MANIFEST) -f $(CONTEXT)/Containerfile $(CONTEXT)

ci-hub-support-oci-save:
${CONTAINER_MANAGER} save -o $(CI_HUB_SUPPORT_SAVE).tar $(CI_HUB_SUPPORT):$(CI_HUB_SUPPORT_V)

sci-hub-support-oci-load:
${CONTAINER_MANAGER} load -i $(CI_HUB_SUPPORT_SAVE).tar

ci-hub-support-oci-push:
ifndef IMAGE
IMAGE = $(CI_HUB_SUPPORT):$(CI_HUB_SUPPORT_V)
endif
${CONTAINER_MANAGER} push $(IMAGE)



45 changes: 0 additions & 45 deletions base-pipeline.yaml

This file was deleted.

21 changes: 21 additions & 0 deletions ci-hub-support/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# ubi 9.4-1227.1726694542
FROM registry.access.redhat.com/ubi9-minimal@sha256:f5d2c6a1e0c86e4234ea601552dbabb4ced0e013a1efcbfb439f1f6a7a9275b0

LABEL org.opencontainers.image.authors="CodeReady Containers <[email protected]>"

ENV AWS_CLI_VERSION 2.17.63
ENV AWS_CLI_URL https://awscli.amazonaws.com/awscli-exe-linux-x86_64-${AWS_CLI_VERSION}.zip

# YQ
ENV YQ_VERSION=4.11.2
ENV YQ_BINARY_URL=https://github.com/mikefarah/yq/releases/download/v${YQ_VERSION}/yq_linux_amd64

RUN microdnf install -y openssh-clients sshpass unzip zip bash jq findutils \
&& curl -Lo /usr/local/bin/yq "${YQ_BINARY_URL}" \
&& chmod +x /usr/local/bin/yq \
&& curl ${AWS_CLI_URL} -o awscliv2.zip \
&& unzip awscliv2.zip \
&& ./aws/install \
&& microdnf clean all \
&& rm -rf /var/cache/yum

2 changes: 2 additions & 0 deletions ci-hub-support/release-info
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
quay.io/devtools-qe-incubator/ci-hub-support
1.0.0-dev

0 comments on commit ed2e79f

Please sign in to comment.