diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4327bde..ac10846 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ on: branches: [main] jobs: - build-and-lint: + build-and-test: runs-on: ubuntu-latest timeout-minutes: 15 @@ -29,17 +29,3 @@ jobs: - name: Build project run: npm run build - - docker-build: - runs-on: ubuntu-latest - timeout-minutes: 15 - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Build Docker image - run: docker build -t sovd-web-ui:test -f Dockerfile . diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..a778035 --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,66 @@ +name: Docker Publish + +on: + pull_request: + branches: + - main + push: + branches: + - main + tags: + - 'v*' + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GitHub Container Registry + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + # latest on main branch + type=raw,value=latest,enable={{is_default_branch}} + # version tag (v1.2.3 -> 1.2.3) + type=semver,pattern={{version}} + # major.minor (v1.2.3 -> 1.2) + type=semver,pattern={{major}}.{{minor}} + # major only (v1.2.3 -> 1) + type=semver,pattern={{major}} + # sha for traceability + type=sha,prefix=sha-,format=short + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + # amd64 only - arm64 fails due to QEMU emulation issues with npm ci + platforms: linux/amd64 diff --git a/README.md b/README.md index c55f938..3787783 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # sovd_web_ui [![CI](https://github.com/selfpatch/sovd_web_ui/actions/workflows/ci.yml/badge.svg)](https://github.com/selfpatch/sovd_web_ui/actions/workflows/ci.yml) +[![GHCR](https://img.shields.io/badge/GHCR-ghcr.io%2Fselfpatch%2Fsovd__web__ui-blue?logo=github)](https://github.com/selfpatch/sovd_web_ui/pkgs/container/sovd_web_ui) Simple, open-source web UI for browsing SOVD (Service-Oriented Vehicle Diagnostics) entity trees via discovery endpoints. @@ -33,12 +34,28 @@ This tool is designed for developers and integrators working with SOVD-compatibl ### Using Docker ```bash +# Pull from GitHub Container Registry +docker pull ghcr.io/selfpatch/sovd_web_ui:latest +docker run -p 8080:80 ghcr.io/selfpatch/sovd_web_ui:latest + +# Or build locally docker build -t sovd_web_ui . docker run -p 8080:80 sovd_web_ui ``` Then open http://localhost:8080 in your browser. +#### Docker Image Tags + +Docker images are automatically published to GitHub Container Registry via GitHub Actions: + +| Trigger | Image Tags | +|---------|------------| +| Push/merge to `main` | `latest`, `sha-` | +| Git tag `v1.2.3` | `1.2.3`, `1.2`, `1`, `sha-` | + +> **Note:** Images are currently built for `linux/amd64` only. ARM64 support is planned. + ### Development ```bash