name: Build Gateway on: workflow_dispatch: push: branches: - master paths: - 'FictionArchive.API/**' env: REGISTRY: ${{ gitea.server_url }} IMAGE_NAME: ${{ gitea.repository_owner }}/fictionarchive-api jobs: build-gateway: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Setup .NET uses: actions/setup-dotnet@v4 with: dotnet-version: '8.0.x' - name: Install Fusion CLI run: dotnet tool install -g HotChocolate.Fusion.CommandLine - name: Create subgraphs directory run: mkdir -p subgraphs # Download all subgraph packages from latest successful builds - name: Download Novel Service subgraph uses: actions/download-artifact@v4 with: name: novel-service-subgraph path: subgraphs/novel continue-on-error: true - name: Download Translation Service subgraph uses: actions/download-artifact@v4 with: name: translation-service-subgraph path: subgraphs/translation continue-on-error: true - name: Download Scheduler Service subgraph uses: actions/download-artifact@v4 with: name: scheduler-service-subgraph path: subgraphs/scheduler continue-on-error: true - name: Download User Service subgraph uses: actions/download-artifact@v4 with: name: user-service-subgraph path: subgraphs/user continue-on-error: true - name: Download File Service subgraph uses: actions/download-artifact@v4 with: name: file-service-subgraph path: subgraphs/file continue-on-error: true - name: Configure subgraph URLs for Docker run: | for fsp in subgraphs/*/*.fsp; do if [ -f "$fsp" ]; then dir=$(dirname "$fsp") name=$(basename "$dir") url="http://${name}-service:8080/graphql" echo "Setting $name URL to $url" fusion subgraph config set http --url "$url" -c "$fsp" fi done - name: Compose gateway run: | cd FictionArchive.API rm -f gateway.fgp for fsp in ../subgraphs/*/*.fsp; do if [ -f "$fsp" ]; then echo "Composing: $fsp" fusion compose -p gateway.fgp -s "$fsp" fi done - name: Restore dependencies run: dotnet restore FictionArchive.API/FictionArchive.API.csproj - name: Build gateway run: dotnet build FictionArchive.API/FictionArchive.API.csproj -c Release --no-restore -p:SkipFusionBuild=true - name: Run tests run: dotnet test FictionArchive.sln -c Release --no-build --verbosity normal continue-on-error: true - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Log in to Gitea Container Registry uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ gitea.actor }} password: ${{ secrets.REGISTRY_TOKEN }} - name: Build and push Docker image uses: docker/build-push-action@v6 with: context: . file: FictionArchive.API/Dockerfile push: true tags: | ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ gitea.sha }} cache-from: type=gha cache-to: type=gha,mode=max