Skip to content

Commit

Permalink
I412 GitHub action (#413)
Browse files Browse the repository at this point in the history
  • Loading branch information
pushyamig committed Mar 4, 2024
1 parent 91f344a commit 4288096
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 32 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/ccm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: CCM Build/Release

on:
push:
# takes muliple branch names
branches:
- main
- '[0-9][0-9][0-9][0-9].[0-9][0-9].*' # 2021.01.x
tags:
- '[0-9][0-9][0-9][0-9].[0-9][0-9].[0-9][0-9]' # 2021.01.01

workflow_dispatch:
inputs:
version:
description: 'Version'
required: true
default: 'YYYY.MINOR.MICRO'
env:
REPO_URL: ${{ github.repository }}

jobs:
build:
# to test a feature, change the repo name to your github id
if: github.repository_owner == 'tl-its-umich-edu'
runs-on: ubuntu-latest
steps:

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

- name: Extract branch name
id: extract_branch
run: echo "BRANCH_NAME=$(basename ${{ github.ref }})" >> $GITHUB_ENV

- name: build Docker image
run: |
cd ccm_web
docker build . --tag ghcr.io/${{ env.REPO_URL }}:${BRANCH_NAME}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push Docker image to GitHub Container Registry
run: |
docker push ghcr.io/${{ env.REPO_URL }}:${BRANCH_NAME}
release:
# Making sure that release only runs for tag pushes
if: startsWith(github.ref, 'refs/tags/') && github.repository_owner == 'tl-its-umich-edu'
needs: build # This ensures the build job finishes successfully before starting this job
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Draft Release
id: create_release
uses: softprops/action-gh-release@v1
with:
draft: true
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,15 @@ This repository contains modified portions of the npm package
[@types/ltijs](https://www.npmjs.com/package/@types/ltijs), which carries an MIT license.
See `ccm_web/server/localTypes/ltijs/index.d.ts` for more information and the modified code.
This code will hopefully only remain in this repository temporarily.

## GitHub Action
1. The [GitHub action](https://docs.github.com/en/actions/quickstart) configuration in [/.github/workflows/ccm.yml](../.github/workflows/ccm.yml) uses Dockerfile to build the app, then pushes the image to the [GitHub container registry (GHCR)](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry).
2. The action is triggered whenever a commit is made to the `main` branch. E.g., when a pull request is merged to `main`.
3. OpenShift projects can periodically pull this image from GHCR. Configure only **_NON-PRODUCTION_** CCM projects to pull the image…
```sh
oc tag ghcr.io/tl-its-umich-edu/canvas-course-manager-next:latest canvas-course-manager-next:latest --scheduled --reference-policy=local
```
See the OpenShift documentation "[Managing image streams: Configuring periodic importing of image stream tags](https://docs.openshift.com/container-platform/4.11/openshift_images/image-streams-manage.html#images-imagestream-import_image-streams-managing)" for details.

`reference-policy=local` : If you want to instruct OpenShift Container Platform to always fetch the tagged image from the [integrated registry](https://docs.openshift.com/container-platform/4.11/openshift_images/managing_images/tagging-images.html#images-add-tags-to-imagestreams_tagging-images)

32 changes: 0 additions & 32 deletions ccm_web/Dockerfile.openshift

This file was deleted.

0 comments on commit 4288096

Please sign in to comment.