name: Docker on: push: branches: [main] tags: - 'v*' workflow_dispatch: permissions: contents: read packages: write env: REGISTRY: ghcr.io jobs: build-and-push: runs-on: ubuntu-latest steps: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 with: fetch-depth: 0 persist-credentials: false - uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0 with: go-version-file: go.mod - name: Restore pricing snapshot run: go run ./internal/pricing/cmd/litellm-snapshot -restore - name: Compute image build metadata id: vars shell: bash run: | if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then VERSION="${GITHUB_REF#refs/tags/}" else VERSION="dev" fi echo "version=${VERSION}" >> "$GITHUB_OUTPUT" echo "commit=${GITHUB_SHA::8}" >> "$GITHUB_OUTPUT" echo "build_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> "$GITHUB_OUTPUT" echo "image=${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT" - uses: docker/setup-qemu-action@06116385d9baf250c9f4dcb4858b16962ea869c3 # v4.1.0 - uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0 - uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - uses: docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 # v6.1.0 id: meta with: images: ${{ env.REGISTRY }}/${{ steps.vars.outputs.image }} tags: | type=raw,value=latest,enable={{is_default_branch}} type=raw,value=stable,enable=${{ startsWith(github.ref, 'refs/tags/v') }} type=semver,pattern={{version}} labels: | org.opencontainers.image.title=agentsview org.opencontainers.image.description=Local web viewer for AI agent sessions - name: Build and push Docker image uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0 with: context: . file: ./Dockerfile platforms: linux/amd64,linux/arm64 push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} build-args: | VERSION=${{ steps.vars.outputs.version }} COMMIT=${{ steps.vars.outputs.commit }} BUILD_DATE=${{ steps.vars.outputs.build_date }} cache-from: type=gha cache-to: type=gha,mode=max