add krakens analytics: new implementations #18
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: Frontend Build | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| paths: | |
| - 'frontend/**' | |
| - '.github/workflows/frontend.yml' | |
| pull_request: | |
| branches: [ main ] | |
| paths: | |
| - 'frontend/**' | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }}/frontend | |
| jobs: | |
| build: | |
| name: Build Frontend | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '24' | |
| cache: 'yarn' | |
| cache-dependency-path: frontend/yarn.lock | |
| - name: Install dependencies | |
| working-directory: ./frontend | |
| run: yarn install --frozen-lockfile | |
| - name: Build application | |
| working-directory: ./frontend | |
| run: yarn build | |
| env: | |
| NEXT_PUBLIC_API_URL: ${{ secrets.NEXT_PUBLIC_API_URL || 'https://api.krakens.nesohq.org' }} | |
| NEXT_PUBLIC_FRONTEND_URL: ${{ secrets.NEXT_PUBLIC_FRONTEND_URL || 'https://krakens.nesohq.org' }} | |
| docker: | |
| name: Build & Push Docker Image | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: github.event_name == 'push' | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Log in to Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=ref,event=branch | |
| type=ref,event=pr | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=sha,prefix={{branch}}- | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ./frontend | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| build-args: | | |
| NEXT_PUBLIC_API_URL=${{ secrets.NEXT_PUBLIC_API_URL || 'https://api.krakens.nesohq.org' }} | |
| NEXT_PUBLIC_FRONTEND_URL=${{ secrets.NEXT_PUBLIC_FRONTEND_URL || 'https://krakens.nesohq.org' }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: π Trigger Infrastructure Staging Deployment | |
| if: success() && github.ref == 'refs/heads/main' | |
| run: | | |
| curl -X POST \ | |
| -H "Authorization: token ${{ secrets.INFRA_REPO_TOKEN }}" \ | |
| -H "Accept: application/vnd.github.v3+json" \ | |
| https://api.github.com/repos/opskraken/nesohq-infra/dispatches \ | |
| -d '{"event_type":"deploy-staging"}' | |
| - name: π Deployment triggered | |
| if: success() && github.ref == 'refs/heads/main' | |
| run: | | |
| echo "β Frontend image built and pushed successfully!" | |
| echo "π Infrastructure deployment triggered for staging environment" | |
| echo "π¦ Image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" |