diff --git a/.github/workflows/ondemand.yml b/.github/workflows/ondemand.yml new file mode 100644 index 0000000..8c92707 --- /dev/null +++ b/.github/workflows/ondemand.yml @@ -0,0 +1,68 @@ +name: Build and publish ondemand container +on: + pull_request: + workflow_dispatch: + push: + schedule: + # rebuild image every Monday morning + - cron: '43 4 * * 1' + +jobs: + build_publish: + 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: | + echo IMAGE_TAG=$(date +"%Y%m%d") >> $GITHUB_ENV + + - name: Determine latest release of ondemand + id: getlatestrelease + run: | + release=$(curl -s -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/OSC/ondemand/releases/latest | jq -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 }}' + + - name: Build Image + uses: redhat-actions/buildah-build@v2 + id: build-image + with: + tags: latest ${{ github.sha }} ${{ env.IMAGE_TAG }} ${{ env.RELEASE }} + image: ondemand + containerfiles: "./Containerfile" + + - 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 diff --git a/ondemand/README.md b/ondemand/README.md new file mode 100644 index 0000000..8d172bc --- /dev/null +++ b/ondemand/README.md @@ -0,0 +1,5 @@ +# 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