name: Build, Test & Push Frontend # Trigger the workflow on: push: branches: - main jobs: # ------------------------------------------------------------------ # JOB 1: Code integrity and quality gates (CI) # ------------------------------------------------------------------ quality-check: runs-on: ubuntu-latest steps: - name: Checkout Code uses: actions/checkout@v4 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '24' cache: 'npm' - name: Install Dependencies run: npm ci # Run ESLint if configured in package.json - name: Lint & Type Check run: npm run lint --if-present # Build the Vite React application - name: Build Production run: npm run build # ------------------------------------------------------------------ # JOB 2: Docker Build & Push (CD) # Runs only if 'quality-check' is successful and we are on branch main # ------------------------------------------------------------------ docker: needs: quality-check runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Prepare tag id: prep shell: bash run: | # Sanitize branch name for valid Docker tags BRANCH="${GITHUB_REF_NAME}" BRANCH="${BRANCH//\//-}" BRANCH="$(echo "$BRANCH" | tr '[:upper:]' '[:lower:]')" echo "branch=$BRANCH" >> "$GITHUB_OUTPUT" echo "sha=${GITHUB_SHA::12}" >> "$GITHUB_OUTPUT" - uses: docker/setup-buildx-action@v3 - uses: docker/login-action@v3 with: registry: git.andreas-dahm.eu username: ${{ github.repository_owner }} password: ${{ secrets.TOKEN_GITEA }} - name: Build & Push uses: docker/build-push-action@v6 with: context: . push: true tags: | git.andreas-dahm.eu/${{ github.repository_owner }}/tobeplayed-frontend:${{ steps.prep.outputs.branch }} git.andreas-dahm.eu/${{ github.repository_owner }}/tobeplayed-frontend:${{ steps.prep.outputs.branch }}-${{ steps.prep.outputs.sha }} git.andreas-dahm.eu/${{ github.repository_owner }}/tobeplayed-frontend:latest