Changing the build file to support multi platforms #17
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 & push multi-arch image (temp) | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: package/docker/Dockerfile | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: ghcr.io/bahnew/clinical-frontend:temp | |
| - name: Scan Docker image for vulnerabilities | |
| uses: aquasecurity/trivy-action@0.30.0 | |
| with: | |
| image-ref: 'ghcr.io/bahnew/clinical-frontend:temp' | |
| format: 'table' | |
| exit-code: '1' | |
| severity: 'CRITICAL' | |
| - name: Retag & push final image | |
| if: success() | |
| run: | | |
| docker manifest create ghcr.io/bahnew/clinical-frontend:latest \ | |
| --amend ghcr.io/bahnew/clinical-frontend:temp | |
| docker manifest 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"}' |