name: Docker Image on: push: branches: - main workflow_dispatch: concurrency: group: docker-${{ github.ref }} cancel-in-progress: true env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} GOPROXY: https://proxy.golang.org,direct GOPRIVATE: github.com/Silo-Server/* GONOSUMDB: github.com/Silo-Server/* jobs: build: runs-on: [self-hosted, linux] permissions: contents: read packages: write steps: - name: Checkout uses: actions/checkout@v5 - name: Set up pnpm uses: pnpm/action-setup@v4 with: version: 10 - name: Set up Node.js uses: actions/setup-node@v5 with: node-version: "22" cache: "pnpm" cache-dependency-path: web/pnpm-lock.yaml - name: Install frontend dependencies working-directory: web run: pnpm install --frozen-lockfile - name: Build frontend assets working-directory: web run: pnpm run build - name: Set up Go uses: actions/setup-go@v6 with: go-version-file: go.mod cache: true cache-dependency-path: go.sum - name: Reject committed local SDK replaces run: | if grep -Eq '^replace github.com/Silo-Server/silo-plugin-sdk => /' go.mod; then echo "go.mod contains a machine-local silo-plugin-sdk replace." exit 1 fi - name: Validate SDK resolves from the module graph env: GOWORK: off run: | sdk_module_json="$(mktemp)" go list -m -json github.com/Silo-Server/silo-plugin-sdk > "$sdk_module_json" if grep -q '"Main": true' "$sdk_module_json"; then echo "silo-plugin-sdk resolved from the local workspace instead of go.mod." cat "$sdk_module_json" exit 1 fi - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 with: name: silo-builder keep-state: true - name: Log in to GitHub 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=raw,value=latest,enable={{is_default_branch}} type=sha,prefix=,format=short - name: Build and push uses: docker/build-push-action@v6 with: context: . push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} build-contexts: | frontend_dist=./web/dist build-args: | BUILD_REVISION=${{ github.sha }} BUILD_DIRTY=false