diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..69fe2e2 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,60 @@ +name: Docker Image CI + +on: + push: + branches: + - main + tags: + - "v*" + pull_request: + branches: + - main + workflow_dispatch: + +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: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=tag + type=sha + + - name: Log in to registry + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/README.md b/README.md index 960e850..470430d 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,10 @@ Then, you can simply use the address and port as the baseURL as you require (htt Read [the docker instrunctions here](https://github.com/RayBytes/ChatMock/blob/main/DOCKER.md) +## Continuous Integration + +Every push or pull request to `main` runs the workflow at `.github/workflows/docker-image.yml`, which builds multi-arch (linux/amd64 + linux/arm64) Docker images and (on pushes) publishes them to GitHub's container registry using the built-in `GITHUB_TOKEN`. The image is tagged for the branch, tag, and commit SHA, so you can pull `ghcr.io//ChatMock:main` (or whatever tag was built) directly after CI completes. If you prefer Docker Hub or another registry, update the `REGISTRY` or `IMAGE_NAME` env vars in the workflow file accordingly. + # Examples ### Python @@ -171,5 +175,3 @@ When the model returns a thinking summary, the model will send back thinking tag [![Star History Chart](https://api.star-history.com/svg?repos=RayBytes/ChatMock&type=Timeline)](https://www.star-history.com/#RayBytes/ChatMock&Timeline) - -