Skip to content

build: bump MongoDb version to '5.0.31' #162

build: bump MongoDb version to '5.0.31'

build: bump MongoDb version to '5.0.31' #162

name: Publish Docker image
on:
push:
tags:
- '*'
env:
build_latest: false
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 17
uses: actions/[email protected]
with:
distribution: 'corretto'
java-version: 17
- 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: 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: .
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
- name: Run Trivy vulnerability scanner
if: ${{ env.build_latest == 'auto' }}
uses: aquasecurity/trivy-action@master
with:
image-ref: 'mongocamp/mongodb:latest'
format: 'sarif'
output: 'trivy-results.sarif'
ignore-unfixed: true
- name: Upload Trivy scan results to GitHub Security tab
if: ${{ env.build_latest == 'auto' }}
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: 'trivy-results.sarif'