Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add github action to build upstream Ondemand container (AB#22789) #28

Merged
merged 4 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions .github/workflows/build-publish-containers.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
name: Build and publish container images
on:
pull_request:
workflow_dispatch:
push:
schedule:
# rebuild image every Monday morning
- cron: '43 3 * * 1'
push:
paths-ignore:
- 'ondemand/**'
pull_request:
paths-ignore:
- 'ondemand/**'

jobs:
build_publish:
Expand Down Expand Up @@ -41,8 +44,9 @@ jobs:
- name: Determine latest release of VSTS Agent
if: matrix.tag == 'azure-pipelines-azureagent'
id: getvstsagentlatest
shell: bash
run: |
release=$(curl -s -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/microsoft/azure-pipelines-agent/releases/latest | jq -r .name)
release=$(curl -s -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/microsoft/azure-pipelines-agent/releases/latest | jq -e -r .name)
echo "Building release $release"
echo "RELEASE=${release:1}" >> $GITHUB_ENV

Expand All @@ -55,7 +59,7 @@ jobs:
path: azure-pipelines-jupyterhub/vsc-config

- name: Build Image
uses: redhat-actions/buildah-build@v2.13
uses: redhat-actions/buildah-build@v2
id: build-image
with:
tags: latest ${{ github.sha }} ${{ env.IMAGE_TAG }} ${{env.RELEASE}}
Expand All @@ -65,7 +69,7 @@ jobs:
operator_name=${{ secrets.JH_USERNAME }}
operator_uid=${{ secrets.JH_UID }}
az_ag_release=${{ env.RELEASE }}
dockerfiles: |
containerfiles: |
./${{ matrix.tag }}/Dockerfile

- name: Print image name and tags
Expand All @@ -74,7 +78,7 @@ jobs:
- name: Publish image on ghcr.io
id: push-to-ghcr
if: env.PUBLISH_IMAGES
uses: redhat-actions/push-to-registry@v2.8
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
Expand Down
86 changes: 86 additions & 0 deletions .github/workflows/build-publish-ondemand.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Build and publish ondemand container
on:
workflow_dispatch:
inputs:
upstream_version:
type: string
description: Which version should be build?
schedule:
# rebuild image every Monday morning
- cron: '43 3 * * 1'
push:
paths:
- 'ondemand/**'
pull_request:
paths:
- 'ondemand/**'

env:
ood_release_handle: ${{ inputs.upstream_version && format('tags/{0}', inputs.upstream_version) || 'latest' }}

jobs:
build_publish_ondemand:
name: Build/publish ondemand container
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Check if we should publish
if: >-
(github.event_name == 'push' ||
github.event_name == 'schedule' ||
github.event_name == 'workflow_dispatch') &&
github.ref_name == 'main'
run: |
echo PUBLISH_IMAGES=1 >> $GITHUB_ENV

- name: Set a tag based on the date
run: |
IMAGE_TAG=$(date +"%Y%m%d")
echo IMAGE_TAG=$IMAGE_TAG >> $GITHUB_ENV
echo "Image tag is $IMAGE_TAG"

- name: Determine release of ondemand
id: getlatestrelease
shell: bash
run: |
release=$(curl -s -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/OSC/ondemand/releases/${{ env.ood_release_handle }} | jq -e -r .name)
echo "Building release $release"
echo "RELEASE=${release}" >> $GITHUB_ENV

- name: Check out the repo
uses: actions/checkout@v4
with:
repository: 'OSC/ondemand'
ref: '${{ env.RELEASE }}'
path: 'ondemand'

- name: Build Image
uses: redhat-actions/buildah-build@v2
id: build-image
with:
tags: latest ${{ env.IMAGE_TAG }} ${{ env.RELEASE }}
image: ondemand
containerfiles: ondemand/Dockerfile
context: ondemand
build-args: |
VERSION=${{ env.RELEASE }}

- name: Print image name and tags
run: echo "Image ${{ steps.build-image.outputs.image }} build with tags ${{ steps.build-image.outputs.tags }}" >> $GITHUB_STEP_SUMMARY

- name: Publish image on ghcr.io
id: push-to-ghcr
if: env.PUBLISH_IMAGES
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: ghcr.io/${{ github.repository_owner }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Print image url
if: env.PUBLISH_IMAGES
run: echo "Image pushed to ${{ steps.push-to-ghcr.outputs.registry-paths }}" >> $GITHUB_STEP_SUMMARY
12 changes: 12 additions & 0 deletions ondemand/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Container for OpenOnDemand

This is to build the upstream container for OpenOnDemand as found in their upstream repo: https://github.com/OSC/ondemand

The dockerfile is at https://github.com/OSC/ondemand/blob/master/Dockerfile

The github action will always build the latest version and tag it with 'latest', the version itself ('v3.1.7') and the date.

Pull from ghcr.io by:
```
podman pull ghcr.io/vub-hpc/ondemand:latest
```
Loading