Skip to content

Commit

Permalink
added buildah script and github workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
cjtitus committed Dec 21, 2023
1 parent a327f72 commit 11dabc1
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/build_and_push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build and Push Container Image

on:
push:
tags: ['v*']
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get the latest tag
id: get_tag
run: echo "LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)" >> "$GITHUB_ENV"

- name: Authenticate to ghcr
run: echo ${{ secrets.GHCR_PAT }} | buildah login --username cjtitus --password-stdin ghcr.io

- name: Run build script
run: bash buildah_scripts/build.sh

- name: Push image
run: |
IMAGE_ID=ghcr.io/${{ github.repository }}
# Make sure IMAGE_ID is lowercase for buildah
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
echo $IMAGE_ID
echo "buildah push sst_gui:latest $IMAGE_ID:latest"
buildah push --creds ${{ github.actor }}:${{ secrets.GITHUB_TOKEN }} sst_gui:latest $IMAGE_ID:latest
echo "buildah push sst_gui:latest $IMAGE_ID:$LATEST_TAG"
buildah push sst_gui:latest $IMAGE_ID:$LATEST_TAG
33 changes: 33 additions & 0 deletions buildah_scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#! /usr/bin/bash
set -e
set -o xtrace


script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
host_package_dir=$(dirname "$script_dir")/src
container_package_dir=/usr/local/src/sst_gui

version="0.0.1"

# Check if bluesky:latest image is available locally
if [[ "$(buildah images -q sst:latest)" == "" ]]; then
echo "Image not found locally. Pulling from ghcr.io/nsls-ii-sst..."
buildah pull ghcr.io/nsls-ii-sst/sst:latest
fi

container=$(buildah from sst)
buildah run $container -- dnf -y install qt5-qtbase-devel
buildah run $container -- conda install -y pyqt
buildah run $container -- pip3 install bluesky_queueserver_api

buildah copy $container $host_package_dir $container_package_dir
buildah run --workingdir $container_package_dir $container -- pip3 install .

#buildah config --cmd "sst-gui --config /usr/local/src/sst_gui/sst_gui/test_config.yaml" $container

buildah unmount $container

buildah commit $container sst_gui:$version
buildah commit $container sst_gui:latest

buildah rm $container

0 comments on commit 11dabc1

Please sign in to comment.