Serve-JupyterLab workflow #23
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Serve-JupyterLab workflow | |
on: | |
push: | |
paths: | |
- "serve-jupyterlab/**" | |
# Adds ability to run this workflow manually | |
workflow_dispatch: | |
inputs: | |
logLevel: | |
description: 'Log level' | |
required: true | |
default: 'warning' | |
type: choice | |
options: | |
- info | |
- warning | |
- debug | |
tags: | |
description: 'Manual run' | |
required: false | |
type: boolean | |
jobs: | |
build_and_test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout GitHub Action | |
uses: actions/checkout@main | |
- name: Build test image | |
run: | | |
docker build -t test-image -f ./serve-jupyterlab/Dockerfile.test ./serve-jupyterlab | |
- name: Run Trivy vulnerability scanner | |
uses: aquasecurity/[email protected] | |
with: | |
image-ref: 'test-image' | |
format: 'table' | |
severity: 'CRITICAL,HIGH' | |
security-checks: 'vuln' | |
timeout: '30m0s' | |
exit-code: '0' | |
- name: Run tests | |
env: | |
IMAGE_NAME: test-image | |
run: | | |
pip install -r ./serve-jupyterlab/tests/requirements.txt | |
python3 -m pytest ./serve-jupyterlab | |
push: | |
if: | | |
github.ref == 'refs/heads/main' && | |
github.repository == 'scilifelabdatacentre/serve-images' | |
needs: build_and_test | |
runs-on: ubuntu-latest | |
concurrency: | |
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' | |
cancel-in-progress: true | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout github action | |
uses: actions/checkout@main | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ghcr.io/scilifelabdatacentre/serve-jupyterlab | |
tags: | | |
type=raw,value={{date 'YYMMDD-HHmm' tz='Europe/Stockholm'}} | |
- name: Login to GHCR | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{github.actor}} | |
password: ${{secrets.GITHUB_TOKEN}} | |
- name: Publish image to GHCR | |
uses: docker/build-push-action@v3 | |
with: | |
file: ./serve-jupyterlab/Dockerfile | |
context: ./serve-jupyterlab | |
push: true | |
build-args: version=${{ github.ref_name }} | |
tags: | | |
${{ steps.meta.outputs.tags }} | |
ghcr.io/scilifelabdatacentre/serve-jupyterlab:latest | |
labels: ${{ steps.meta.outputs.labels }} |