name: Build, test, and publish on: push: branches: - main workflow_dispatch: env: IMAGE_NAME: batty1039.startdedicated.net:5000/cms-demo jobs: build-and-test: name: Build and test runs-on: ubuntu-latest steps: - name: Check out source uses: actions/checkout@v4 - name: Set up Go uses: actions/setup-go@v5 with: go-version-file: go.mod cache: true - name: Set up Node.js uses: actions/setup-node@v4 with: node-version: 22 cache: npm cache-dependency-path: ui/app/package-lock.json - name: Install frontend dependencies run: npm ci working-directory: ui/app - name: Build frontend run: npm run build working-directory: ui/app - name: Prepare embedded frontend run: | rm -rf cmd/server/web/dist mkdir -p cmd/server/web/dist cp -R ui/dist/. cmd/server/web/dist/ - name: Run Go tests run: go test ./... - name: Run Go vet run: go vet ./... - name: Build Go backend run: go build ./cmd/server publish-image: name: Build and push Docker image needs: build-and-test runs-on: ubuntu-latest steps: - name: Check out source uses: actions/checkout@v4 - name: Log in to private registry uses: docker/login-action@v3 with: registry: batty1039.startdedicated.net:5000 username: ${{ secrets.REGISTRY_USERNAME }} password: ${{ secrets.REGISTRY_PASSWORD }} - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Build and push image uses: docker/build-push-action@v6 with: context: . file: ./Dockerfile push: true tags: | ${{ env.IMAGE_NAME }}:latest ${{ env.IMAGE_NAME }}:${{ github.sha }} cache-from: type=gha cache-to: type=gha,mode=max