BN-35 | Add. Dockerfile and CI Workflow configuration (#3) #8
This file contains hidden or 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 Publish | |
| on: | |
| push: | |
| branches: [ main ] | |
| workflow_dispatch: | |
| jobs: | |
| build-and-publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| cache: 'yarn' | |
| - name: Install dependencies | |
| run: yarn install --frozen-lockfile | |
| - name: Lint | |
| run: yarn lint | |
| - name: Run tests | |
| run: yarn test | |
| - name: Scan for package vulnerabilities | |
| uses: aquasecurity/trivy-action@0.30.0 | |
| with: | |
| scan-type: 'fs' | |
| format: 'table' | |
| exit-code: '1' | |
| severity: 'CRITICAL' | |
| - name: Build | |
| run: yarn build | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: package/docker/Dockerfile | |
| push: false | |
| load: true | |
| tags: clinical-frontend:local | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Scan Docker image for vulnerabilities | |
| uses: aquasecurity/trivy-action@0.30.0 | |
| with: | |
| image-ref: 'clinical-frontend:local' | |
| format: 'table' | |
| exit-code: '1' | |
| severity: 'CRITICAL' | |
| - name: Tag and push Docker image | |
| run: | | |
| docker tag clinical-frontend:local ghcr.io/bahnew/clinical-frontend:latest | |
| docker push ghcr.io/bahnew/clinical-frontend:latest | |
| - name: Repository Dispatch | |
| run: | | |
| curl -X POST \ | |
| -H "Authorization: token ${{ secrets.INFRA_GITHUB_TOKEN }}" \ | |
| -H "Accept: application/vnd.github.v3+json" \ | |
| https://api.github.com/repos/bahnew/utils/dispatches \ | |
| -d '{"event_type":"clinical-frontend-publish"}' |