adds trufflehog #416
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: Build and Test | |
on: | |
workflow_dispatch: | |
push: | |
branches: [main, develop] | |
paths: | |
- 'apps/ehr/**' | |
- 'apps/intake/**' | |
- 'packages/ehr/**' | |
- 'packages/intake/**' | |
- 'packages/utils/**' | |
- 'packages/ui-components/**' | |
- 'scripts/**' | |
- '.github/**' | |
- '.prettierignore' | |
- 'package.json' | |
pull_request: | |
types: [opened, synchronize, reopened, ready_for_review] | |
paths: | |
- 'apps/ehr/**' | |
- 'apps/intake/**' | |
- 'packages/ehr/**' | |
- 'packages/intake/**' | |
- 'packages/utils/**' | |
- 'packages/ui-components/**' | |
- 'scripts/**' | |
- '.github/**' | |
- '.prettierignore' | |
- 'package.json' | |
jobs: | |
build-and-test: | |
if: github.event.pull_request.draft == false || github.event_name == 'workflow_dispatch' | |
runs-on: ubuntu-latest-8-cores | |
timeout-minutes: 15 | |
steps: | |
- name: Install SSH Client | |
uses: webfactory/ssh-agent@v0.7.0 | |
with: | |
ssh-private-key: ${{ secrets.DEPLOY_OTTEHR_KEY }} | |
# Checkout the main repository | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# Set up Node.js environment | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
- name: TruffleHog -- Check for secrets committed to the repository | |
uses: trufflesecurity/trufflehog@v3.82.13 | |
with: | |
extra_args: --only-verified | |
- name: Check out secrets repo | |
uses: actions/checkout@v4 | |
with: | |
repository: masslight/ottehr-secrets | |
ssh-key: ${{ secrets.DEPLOY_OTTEHR_KEY }} | |
path: 'secrets' | |
- name: Setup secrets | |
run: | | |
mkdir -p packages/ehr/zambdas/.env packages/intake/zambdas/.env | |
cp secrets/zambdas/* packages/ehr/zambdas/.env | |
cp secrets/zambdas/* packages/intake/zambdas/.env | |
mkdir -p apps/ehr/env apps/intake/env | |
cp secrets/ehr/app/.env.local apps/ehr/env/ | |
cp secrets/ehr/app/tests.*.json apps/ehr/env/ | |
cp secrets/intake/app/.env.local apps/intake/env/ | |
cp secrets/intake/app/tests.*.json apps/intake/env/ | |
- name: Cache node modules | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-node-modules | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- name: Install dependencies | |
run: npm ci | |
- name: Run linting | |
run: npm run lint:eslint | |
- name: Run unit tests | |
run: npm run test | |
env: | |
CI: true | |
NODE_OPTIONS: '--max-old-space-size=8192' | |
- name: TruffleHog -- Check for secrets in bundles of publicly available code | |
run: | | |
docker run --rm -v .:/tmp -w /tmp \ | |
ghcr.io/trufflesecurity/trufflehog:3.82.13 \ | |
filesystem .apps/intake/build/assets \ | |
--github-actions \ | |
--only-verified \ | |
--fail | |
- uses: actions/github-script@v7 | |
if: always() | |
with: | |
script: | | |
const success = '${{ job.status }}' === 'success'; | |
await github.rest.repos.createCommitStatus({ | |
...context.repo, | |
sha: context.sha, | |
state: success ? 'success' : 'failure', | |
context: 'CI / Tests', | |
description: success ? 'Tests successful' : 'Tests failed' | |
}); |