Skip to content

Commit a99a42d

Browse files
Move MongoDB Server to dedicated gh action
1 parent 3fc55d9 commit a99a42d

2 files changed

Lines changed: 28 additions & 5 deletions

File tree

.github/actions/mongodb/action.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: MongoDB
2+
description: 'Set up a MongoDB server'
3+
4+
inputs:
5+
mongo-version:
6+
description: 'MongoDB Server version'
7+
required: true
8+
replica-set:
9+
description: 'Replica Set Name'
10+
required: false
11+
default: '_standalone_'
12+
runs:
13+
using: composite
14+
steps:
15+
- name: Start MongoDB Standalone
16+
if: ${{ inputs.replica-set == '_standalone_' }}
17+
run: docker run --rm -d -p 27017:27017 --name mongo mongo:${{ inputs.mongo-version }} --bind_ip_all
18+
- name: Start MongoDB Replica Set
19+
if: ${{ inputs.replica-set != '_standalone_' }}
20+
run: |
21+
echo 'replica'
22+
docker run --rm -d -p 27017:27017 --name mongo mongo:${{ inputs.mongo-version }} --replSet ${{ inputs.replica-set }} --bind_ip_all
23+
sleep 5 # Give mongo a chance to start up
24+
docker run --rm mongo:${{ inputs.mongo-version }} mongosh --host 172.17.0.1 --eval 'rs.initiate({_id: "${{ inputs.replica-set }}", members: [{_id: 0, host: "172.17.0.1:27017"}]})'

.github/workflows/ci.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,11 @@ jobs:
2323
with:
2424
java-version: ${{ matrix.java-version }}
2525
develocity-access-key: '${{ secrets.DEVELOCITY_ACCESS_KEY }}'
26-
- name: Start MongoDB
27-
run: docker run --rm -d -p 27017:27017 --name mongo mongo:${{ matrix.mongo-version }} --replSet rs0 --bind_ip_all
2826
- name: Initialize MongoDB
29-
run: |
30-
sleep 5 # Give mongo a chance to start up
31-
docker run --rm mongo:${{ matrix.mongo-version }} mongosh --host 172.17.0.1 --eval 'rs.initiate({_id: "rs0", members: [{_id: 0, host: "172.17.0.1:27017"}]})'
27+
uses: ./.github/actions/mongodb/
28+
with:
29+
mongo-version: ${{ matrix.mongo-version }}
30+
replica-set: 'rs0'
3231
- name: Build
3332
uses: spring-projects/spring-data-release/actions/maven-build@main
3433
with:

0 commit comments

Comments
 (0)