Skip to content

Commit

Permalink
Initial version of custom action template
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Sundberg <[email protected]>
  • Loading branch information
seansund committed Nov 14, 2024
1 parent 9325805 commit 3857c12
Show file tree
Hide file tree
Showing 36 changed files with 1,191 additions and 750 deletions.
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "npm" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"
28 changes: 28 additions & 0 deletions .github/release-drafter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
categories:
- title: 'Features'
labels:
- 'feature'
- 'enhancement'
- title: 'Bug Fixes'
labels:
- 'fix'
- 'bugfix'
- 'bug'
- title: 'Maintenance'
label: 'chore'
version-resolver:
major:
labels:
- 'major'
minor:
labels:
- 'minor'
patch:
labels:
- 'patch'
default: patch
template: |
$CHANGES
102 changes: 102 additions & 0 deletions .github/workflows/docker-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Docker build

# Controls when the workflow will run
on:
release:
types:
- published
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

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

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

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Login to CNTK Quay
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_CNTK_USERNAME }}
password: ${{ secrets.QUAY_CNTK_TOKEN }}

- name: Setup variables
id: variables
shell: bash
run: |
LATEST_ENABLED="true"
RELEASE_TAG=${GITHUB_REF#refs/tags/}
RELEASE_TAG_ENABLED="false"
if [[ "${GITHUB_REF}" =~ refs/tags ]] && [[ "${RELEASE_TAG}" != "main" ]]; then
RELEASE_TAG_ENABLED="true"
else
RELEASE_TAG="main"
fi
echo "Release tag: ${RELEASE_TAG}"
echo "release-tag=$RELEASE_TAG" >> $GITHUB_OUTPUT
echo "Release tag enabled: $RELEASE_TAG_ENABLED"
echo "release-tag-enabled=$RELEASE_TAG_ENABLED" >> $GITHUB_OUTPUT
echo "Latest enabled: $LATEST_ENABLED"
echo "latest-enabled=$LATEST_ENABLED" >> $GITHUB_OUTPUT
- name: Docker CNTK meta
id: cntk-meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
${{vars.IMAGE_BASE}}
# Docker tags based on the following events/attributes
tags: |
type=raw,value=${{ steps.variables.outputs.release-tag }},enable=${{ steps.variables.outputs.release-tag-enabled }}
type=raw,value=latest
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
push: ${{ github.event_name != 'pull_request' }}
platforms: linux/amd64,linux/arm64
tags: ${{ steps.cntk-meta.outputs.tags }}
labels: ${{ steps.cntk-meta.outputs.labels }}

notify:
needs: ["build"]
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' }}

strategy:
matrix:
repo:
- ${{ github.repository }}

steps:
- name: Repository dispatch ${{ matrix.repo }}
uses: cloud-native-toolkit/action-repository-dispatch@main
with:
notifyRepo: ${{ matrix.repo }}
eventType: released
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
25 changes: 25 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Release module

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [ main ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
release:
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Drafts your next Release notes as Pull Requests are merged into "master"
- uses: rlespinasse/github-slug-action@v5

- uses: release-drafter/release-drafter@v6
with:
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
config-name: release-drafter.yaml
publish: true
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM openjdk:8 as builder

WORKDIR /source

COPY . .
RUN ./gradlew jar

FROM docker.io/alpine:3.20.3

WORKDIR /op-ext-lib

COPY --from=builder /source/build/libs/*.jar .

WORKDIR /scripts

COPY scripts/copyJars.sh .

ENTRYPOINT [ "./copyJars.sh" ]
25 changes: 22 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,25 @@
## Deployment

```shell
oc cp test-custom-action.jar ${NS}/${OPENPAGES_POD_NAME}:/opt/ibm/OpenPages/aurora/op-ext-lib/test-custom-action.jar
oc patch sts ${OPENPAGES_STS_NAME} --patch-file ${PWD}/patch/openpages-patch.yaml
```

where:
- `NS` is the namespace where OpenPages has been deployed
- `OPENPAGES_POD_NAME` is the name of the pod in the namespace, e.g. `openpages-openpages-1-sts-0`
- `OPENPAGES_STS_NAME` is the name of the stateful set in the namespace, e.g. `openpages-openpagesinstance-cr-sts`

## Version update

```shell
oc edit sts openpages-openpagesinstance-cr-sts
```

Update the version number for the `openpages-actions` image

## Logs

```shell
oc logs openpages-openpagesinstance-cr-sts-0
```

## Development

Expand All @@ -22,3 +35,9 @@ podman run --interactive --tty -v $PWD:/workspace openjdk:8 bash
cd /workspace
./gradlew jar
```

The container image is pushed to this location in Quay - https://quay.io/repository/ibm_ecosystem_engineering/openpages-action

## Acknowledgements

Thanks to Randy Phoa for the provided roadmap - https://randyphoa.com/ai-governance-on-cloud-pak-for-data-with-openpages-custom-workflow-actions-555473c060c1
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ repositories {
}

java {
sourceCompatibility = "1.5"
targetCompatibility = "1.5"
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
}

dependencies {
Expand Down
12 changes: 12 additions & 0 deletions patch/build-patch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

SCRIPT_DIR=$(cd $(dirname "$0"); pwd -P)

# Test for jq and logged in oc cli

IMAGE_NAME=$(oc get sts openpages-openpagesinstance-cr-sts -o json | jq -r '.spec.template.spec.containers[] | select(.name == "openpages-opapp").image')

echo "Replacing image in template: ${IMAGE_NAME}"

cat "${SCRIPT_DIR}/openpages-patch-template.yaml" | sed "s~OP_IMAGE~${IMAGE_NAME}~g" > "${SCRIPT_DIR}/openpages-patch.yaml"

31 changes: 31 additions & 0 deletions patch/openpages-patch-template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
spec:
template:
spec:
volumes:
- emptyDir: {}
name: openpages-openpagesinstance-cr-ext-lib-volume
initContainers:
- name: openpages-save-original-libs
image: OP_IMAGE
imagePullPolicy: IfNotPresent
volumeMounts:
- mountPath: /target
name: openpages-openpagesinstance-cr-ext-lib-volume
command:
- cp
- "/opt/ibm/OpenPages/aurora/op-ext-lib/*.jar"
- /target
- name: openpages-ext-lib-update
image: quay.io/ibm_ecosystem_engineering/action-helloworld:v0.1.0
imagePullPolicy: Always
volumeMounts:
- mountPath: /target
name: openpages-openpagesinstance-cr-ext-lib-volume
env:
- name: TARGET
value: /target
containers:
- name: openpages-opapp
volumeMounts:
- name: openpages-openpagesinstance-cr-ext-lib-volume
mountPath: /opt/ibm/OpenPages/aurora/op-ext-lib
14 changes: 14 additions & 0 deletions scripts/copyJars.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

if [ -n "${1}" ]; then
TARGET="${1}"
fi

if [ -z "${TARGET}" ]; then
echo "TARGET must be set"
exit 1
fi

mkdir -p "${TARGET}"

cp /op-ext-lib/* "${TARGET}"
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
rootProject.name = 'confidenceindex-customactions'
rootProject.name = 'template-openpages-action'

Loading

0 comments on commit 3857c12

Please sign in to comment.