Skip to content

deploying frontend+backend #277

deploying frontend+backend

deploying frontend+backend #277

Workflow file for this run

name: Pull Request
on:
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
builds:
name: Builds
uses: ./.github/workflows/_build.yml
strategy:
matrix:
component: [backend, frontend]
include:
- component: backend
triggers: ('backend/')
- component: frontend
triggers: ('frontend/')
secrets:
gh_token: ${{ secrets.GHCR_TOKEN }}
with:
component: ${{ matrix.component }}
img_build: ${{ github.event.number }}
img_fallback: test
triggers: ${{ matrix.triggers }}
tests:
name: Unit Tests
uses: ./.github/workflows/_code-cov.yml
strategy:
matrix:
component: [backend]
secrets:
gh_token: ${{ secrets.GHCR_TOKEN }}
with:
component: ${{ matrix.component }}
lcov_file: ${{ matrix.component }}/coverage/lcov.info
test_cmd: npm run test:cov
#sonarcloud:
# name: Static Analysis
# needs:
# - tests
# runs-on: ubuntu-22.04
# steps:
# # Disable shallow clone for SonarCloud analysis
# - uses: actions/checkout@v3
# with:
# fetch-depth: 0
# - name: Get backend coverage from cache
# uses: actions/cache@v3
# with:
# path: backend/coverage
# key: coverage-backend-${{ github.run_number }}
# restore-keys: |
# coverage-backend-
# - name: Get frontend coverage from cache
# uses: actions/cache@v3
# with:
# path: frontend/coverage
# key: coverage-frontend-${{ github.run_number }}
# restore-keys: |
# coverage-frontend-
# - name: SonarCloud Scan
# uses: SonarSource/sonarcloud-github-action@master
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# with:
# args: >
# -Dsonar.exclusions=**/test/**,.github/**/*,*.md
# -Dsonar.organization=bcgov-sonarcloud
# -Dsonar.javascript.lcov.reportPaths=backend/coverage/lcov.info,frontend/coverage/lcov.info
# -Dsonar.cobertura.reportPaths=backend/coverage/cobertura-coverage.xml,frontend/coverage/cobertura-coverage.xml
# -Dsonar.project.monorepo.enabled=true
# -Dsonar.projectKey=${{ github.event.repository.name }}
# -Dsonar.sources=backend,frontend
# -Dsonar.tests=backend/test,frontend/test
deploys:
name: Deploys
needs:
- builds
# If any of the prerequs created a build, then deploy
if: contains(needs.*.outputs.build, 'true')
uses: ./.github/workflows/_deploy.yml
strategy:
matrix:
component: [backend, database, frontend]
include:
- component: database
overwrite: false
template_file: .github/openshift/deploy.database.yml
template_vars: -p ZONE=${{ github.event.number }}
- component: backend
overwrite: true
template_file: .github/openshift/deploy.backend.yml
template_vars: -p ZONE=${{ github.event.number }} -p PROMOTE=${{ github.repository }}:${{ github.event.number }}-backend
- component: frontend
overwrite: true
template_file: .github/openshift/deploy.frontend.yml
template_vars: -p ZONE=${{ github.event.number }} -p PROMOTE=${{ github.repository }}:${{ github.event.number }}-frontend
secrets:
oc_namespace: ${{ secrets.OC_NAMESPACE }}
oc_server: ${{ secrets.OC_SERVER }}
oc_token: ${{ secrets.OC_TOKEN }}
with:
component: ${{ matrix.component }}
overwrite: ${{ matrix.overwrite }}
template_file: ${{ matrix.template_file }}
template_vars: ${{ matrix.template_vars }}
post-deploy:
name: Post-deploy
needs:
- deploys
env:
DOMAIN: apps.silver.devops.gov.bc.ca
NAME: nr-ticdi
runs-on: ubuntu-22.04
steps:
- name: Comment with links
uses: mshick/add-pr-comment@v1
env:
GITHUB_TOKEN: ${{ secrets.GHCR_TOKEN }}
with:
allow-repeats: false
message: |
DEV deployments have completed successfully!
[Backend](https://${{ env.NAME }}-${{ github.event.number }}-backend.${{ env.DOMAIN }}/) available
[Frontend](https://${{ env.NAME }}-${{ github.event.number }}-frontend.${{ env.DOMAIN }}/) available
# # Uncomment to view GitHub context object
# # https://docs.github.com/en/actions/learn-github-actions/contexts
# view-context:
# name: View GitHub Context
# runs-on: ubuntu-22.04
# steps:
# - name: Echo GitHub context
# uses: satackey/[email protected]
# with:
# script: |
# const github = require('@actions/github');
# console.log(JSON.stringify(github, null, 2));