Skip to content

oop-web build

oop-web build #493

Workflow file for this run

name: oop-web build
on:
push:
paths:
- "oop/src/**/*.html"
- "oop/src/**/*.ts"
- "oop/src/**/*.js"
- "oop/src/**/*.scss"
- "oop/package*.json"
workflow_dispatch:
env:
NAMESPACE: a3c641-tools
ARTIFACT_BUILD_NAME: oop-web-artifact-build
ARTIFACT_IMAGE_NAME: oop-web-artifacts
BUILD_NAME: oop-web-image-build
IMAGE_NAME: oop-web
SOURCE_IMAGE_TAG: latest
TARGET_IMAGE_TAG: dev
jobs:
test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./oop
steps:
- uses: actions/checkout@main
- uses: actions/setup-node@main
with:
node-version: "12"
- name: Install dependencies
run: npm ci
- name: Unit tests
run: npm run test
- name: E2E tests
run: npm run test:e2e-headless
- name: LINTing
run: npm run lint
# - name: OpenAPI Schema
# run: npm run test:schema
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./oop
needs: [test]
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Cache node modules
uses: actions/cache@v1
with:
path: node_modules
key: ${{ runner.OS }}-build-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-build-${{ env.cache-name }}-
${{ runner.OS }}-build-
${{ runner.OS }}-
- name: npm install and build
run: |
npm ci
npm run build --if-present
env:
CI: "true"
image-build:
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
needs: [test, build]
steps:
- uses: redhat-actions/openshift-tools-installer@v1
with:
source: "mirror"
oc: "latest"
- name: Log in to Openshift
run: oc login --token=${{ secrets.OpenShiftToken }} --server=${{ secrets.OpenShiftServerURL}}
- name: Generate Artifact Build
run: oc start-build ${ARTIFACT_BUILD_NAME} -n ${NAMESPACE} --follow
- name: Tag Artifact Build
run: oc tag -n ${NAMESPACE} ${NAMESPACE}/${ARTIFACT_IMAGE_NAME}:${SOURCE_IMAGE_TAG} ${NAMESPACE}/${ARTIFACT_IMAGE_NAME}:${TARGET_IMAGE_TAG}
- name: Generate Image Build
run: oc start-build ${BUILD_NAME} -n ${NAMESPACE} --follow
- name: Time delay
# to give time for Openshift to process the build so it doesn't tag the wrong image
run: sleep 180s
- name: Tag Image Build
run: oc tag -n ${NAMESPACE} ${NAMESPACE}/${IMAGE_NAME}:${SOURCE_IMAGE_TAG} ${NAMESPACE}/${IMAGE_NAME}:${TARGET_IMAGE_TAG}