Skip to content

docs: update samples and docs #155

docs: update samples and docs

docs: update samples and docs #155

name: Publish Docker image
on:
push:
tags:
- '*'
env:
build_latest: auto
jobs:
build_test_container:
name: Build new Test Container
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Log in to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
images: mongocamp/mongodb
flavor: |
latest=false
tags: |
type=raw,value=${{ github.sha }}
- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
test:
name: Run Tests
needs: build_test_container
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
mongodb-port: [ '27017', '4711' ]
mongodb-username: [ 'root', 'test' ]
mongodb-pwd: [ 'NONE', 'hello-world' ]
mongodb-replica-set: [ '', 'my-replication' ]
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Start MongoDB ${{ matrix.mongodb-version }}
uses: MongoCamp/[email protected]
with:
mongodb-version: ${{ github.sha }}
mongodb-port: ${{ matrix.mongodb-port }}
mongodb-username: ${{ matrix.mongodb-username }}
mongodb-pwd: ${{ matrix.mongodb-pwd }}
mongodb-replica-set: ${{ matrix.mongodb-replica-set }}
- name: Set up JDK
uses: coursier/setup-action@main
with:
jvm: corretto:21
apps: sbt scala scalac
- name: Run tests
env:
MONGODB_VERSION: ${{ matrix.mongodb-version }}
MONGODB_PORT: ${{ matrix.mongodb-port }}
MONGODB_USERNAME: ${{ matrix.mongodb-username }}
MONGODB_PWD: ${{ matrix.mongodb-pwd }}
MONGODB_REPLICA_SET: ${{ matrix.mongodb-replica-set }}
run: cd test; sbt test;
cleanup_registry:
name: Cleanup Docker Registry
runs-on: ubuntu-latest
needs: test
steps:
- name: Cleanup Docker Registry
if: always()
continue-on-error: true
run: |
TOKEN=`curl -s -H "Content-Type: application/json" -X POST -H "Content-Type: application/json" -d '{"username":"${{ secrets.DOCKERHUB_USER }}", "password":"${{ secrets.DOCKERHUB_PASSWORD }}"}' "https://hub.docker.com/v2/users/login/" | jq -r .token`
curl "https://hub.docker.com/v2/repositories/mongocamp/mongodb/tags/${{ github.sha }}/" -X DELETE -H "Authorization: JWT ${TOKEN}"
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
needs: test
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Log in to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
images: mongocamp/mongodb
flavor: |
latest=${{ env.build_latest }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
platforms: linux/amd64,linux/arm64/v8
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Update readme at Dockerhub
if: ${{ env.build_latest == 'auto' }}
uses: meeDamian/[email protected]
with:
user: ${{ secrets.DOCKERHUB_USER }}
pass: ${{ secrets.DOCKERHUB_PASSWORD }}
slug: mongocamp/mongodb
readme: README.md
description: true