Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changes #23

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,8 @@ jobs:
mongodb-version: ['4.0', '4.2', '4.4', '5.0', '6.0']

steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
Raj-StepSecurity marked this conversation as resolved.
Show resolved Hide resolved
with:
egress-policy: audit

- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
uses: actions/checkout@v4

- name: Start MongoDB Server
uses: ./
Expand Down
13 changes: 4 additions & 9 deletions .github/workflows/test-auth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,15 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18, 20]
mongodb-version: ['4.4', '5.0', '6.0']
node-version: [20, 22]
mongodb-version: ['5.0', '6.0', '7.0']
mongodb-db: ['ci']
mongodb-username: ['ci']
mongodb-password: ['ci']

steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit

- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
uses: actions/checkout@v4

- name: Start MongoDB Server v${{ matrix.mongodb-version }}
uses: ./
Expand All @@ -33,7 +28,7 @@ jobs:
mongodb-password: ${{ matrix.mongodb-password }}

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

Expand Down
26 changes: 8 additions & 18 deletions .github/workflows/test-replica-set.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18, 20]
mongodb-version: ['4.4', '5.0', '6.0']
node-version: [20, 22]
mongodb-version: ['5.0', '6.0', '7.0']

steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit

- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
uses: actions/checkout@v4

- name: Start MongoDB Server v${{ matrix.mongodb-version }}
uses: ./
Expand All @@ -28,7 +23,7 @@ jobs:
mongodb-replica-set: mongodb-test-rs

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

Expand All @@ -45,19 +40,14 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18, 20]
node-version: [20, 22]
mongodb-port: [23456]
mongodb-version: ['4.4', '5.0', '6.0']
mongodb-version: ['5.0', '6.0', '7.0']

name: MongoDB v${{ matrix.mongodb-version }} RS, Port ${{ matrix.mongodb-port }} — Node.js v${{ matrix.node-version }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit

- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
uses: actions/checkout@v4

- name: Start MongoDB Server v${{ matrix.mongodb-version }}
uses: ./
Expand All @@ -67,7 +57,7 @@ jobs:
mongodb-replica-set: mongodb-test-rs

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

Expand Down
26 changes: 8 additions & 18 deletions .github/workflows/test-single-instance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,20 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18, 20]
mongodb-version: ['4.4', '5.0', '6.0']
node-version: [20, 22]
mongodb-version: ['5.0', '6.0', '7.0']

steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit

- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
uses: actions/checkout@v4

- name: Start MongoDB Server v${{ matrix.mongodb-version }}
uses: ./
with:
mongodb-version: ${{ matrix.mongodb-version }}

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

Expand All @@ -46,18 +41,13 @@ jobs:
strategy:
matrix:
mongodb-port: [12345]
mongodb-version: ['4.4', '5.0', '6.0']
node-version: [18, 20]
mongodb-version: ['5.0', '6.0', '7.0']
node-version: [20, 22]

name: MongoDB v${{ matrix.mongodb-version }}, Port ${{ matrix.mongodb-port }} — Node.js v${{ matrix.node-version }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit

- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
uses: actions/checkout@v4

- name: Start MongoDB Server v${{ matrix.mongodb-version }}
uses: ./
Expand All @@ -66,7 +56,7 @@ jobs:
mongodb-port: ${{ matrix.mongodb-port }}

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
node-version: ${{ matrix.node-version }}

- name: Start MongoDB
uses: step-security/mongodb-github-action@1.11.0
uses: step-security/mongodb-github-action@1.12.0
with:
mongodb-version: ${{ matrix.mongodb-version }}

Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:
node-version: ${{ matrix.node-version }}

- name: Start MongoDB
uses: step-security/mongodb-github-action@1.11.0
uses: step-security/mongodb-github-action@1.12.0
with:
mongodb-version: ${{ matrix.mongodb-version }}
mongodb-replica-set: test-rs
Expand Down Expand Up @@ -117,7 +117,7 @@ jobs:
node-version: ${{ matrix.node-version }}

- name: Start MongoDB
uses: step-security/mongodb-github-action@1.11.0
uses: step-security/mongodb-github-action@1.12.0
with:
mongodb-version: ${{ matrix.mongodb-version }}
mongodb-replica-set: test-rs
Expand Down Expand Up @@ -161,7 +161,7 @@ jobs:
node-version: ${{ matrix.node-version }}

- name: Start MongoDB
uses: step-security/mongodb-github-action@1.11.0
uses: step-security/mongodb-github-action@1.12.0
with:
mongodb-version: ${{ matrix.mongodb-version }}
mongodb-username: supercharge
Expand Down Expand Up @@ -205,7 +205,7 @@ jobs:
node-version: ${{ matrix.node-version }}

- name: Start MongoDB
uses: step-security/mongodb-github-action@1.11.0
uses: step-security/mongodb-github-action@1.12.0
with:
mongodb-version: ${{ matrix.mongodb-version }}
mongodb-container-name: mongodb-${{ matrix.node-version }}-${{ matrix.mongodb-version }}
Expand Down
2 changes: 2 additions & 0 deletions action-types.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# See https://github.com/krzema12/github-actions-typing
inputs:
mongodb-image:
type: string
mongodb-version:
type: string
mongodb-replica-set:
Expand Down
6 changes: 6 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ branding:
color: 'green'

inputs:
mongodb-image:
description: 'MongoDB image to use (defaults to using "mongo" from Docker Hub but you could also use an image from another repository such as Amazons "public.ecr.aws/docker/library/mongo")'
required: false
default: 'mongo'

mongodb-version:
description: 'MongoDB version to use (default "latest")'
required: false
Expand Down Expand Up @@ -45,6 +50,7 @@ runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.mongodb-image }}
- ${{ inputs.mongodb-version }}
- ${{ inputs.mongodb-replica-set }}
- ${{ inputs.mongodb-port }}
Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
},
"devDependencies": {
"@supercharge/eslint-config": "~3.0.1",
"c8": "~9.1.0",
"c8": "~10.1.3",
"eslint": "~8.57.0",
"expect": "~29.7.0",
"mongoose": "~8.4.0",
"mongoose": "~8.9.3",
"uvu": "~0.5.6"
},
"engines": {
Expand All @@ -19,7 +19,9 @@
"homepage": "https://github.com/step-security/mongodb-github-action",
"keywords": [
"github",
"github-action"
"github-action",
"supercharge",
"superchargejs"
],
"license": "MIT",
"repository": {
Expand Down
28 changes: 19 additions & 9 deletions start-mongodb.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#!/bin/sh

# Map input values from the GitHub Actions workflow to shell variables
MONGODB_VERSION=$1
MONGODB_REPLICA_SET=$2
MONGODB_PORT=$3
MONGODB_DB=$4
MONGODB_USERNAME=$5
MONGODB_PASSWORD=$6
MONGODB_CONTAINER_NAME=$7
MONGODB_IMAGE=$1
MONGODB_VERSION=$2
MONGODB_REPLICA_SET=$3
MONGODB_PORT=$4
MONGODB_DB=$5
MONGODB_USERNAME=$6
MONGODB_PASSWORD=$7
MONGODB_CONTAINER_NAME=$8


# validate subscription status
API_URL="https://agent.api.stepsecurity.io/v1/github/$GITHUB_REPOSITORY/actions/subscription"
Expand All @@ -29,6 +31,13 @@ fi
# `mongosh` is used starting from MongoDB 5.x
MONGODB_CLIENT="mongosh --quiet"

if [ -z "$MONGODB_IMAGE" ]; then
echo ""
echo "Missing MongoDB image in the [mongodb-image] input. Received value: $MONGODB_IMAGE"
echo ""

exit 2
fi

if [ -z "$MONGODB_VERSION" ]; then
echo ""
Expand All @@ -38,6 +47,7 @@ if [ -z "$MONGODB_VERSION" ]; then
exit 2
fi

echo "::group::Using MongoDB Docker image $MONGODB_IMAGE:$MONGODB_VERSION"

echo "::group::Selecting correct MongoDB client"
if [ "`echo $MONGODB_VERSION | cut -c 1`" -le "4" ]; then
Expand Down Expand Up @@ -100,7 +110,7 @@ if [ -z "$MONGODB_REPLICA_SET" ]; then
echo " - container-name [$MONGODB_CONTAINER_NAME]"
echo ""

docker run --name $MONGODB_CONTAINER_NAME --publish $MONGODB_PORT:$MONGODB_PORT -e MONGO_INITDB_DATABASE=$MONGODB_DB -e MONGO_INITDB_ROOT_USERNAME=$MONGODB_USERNAME -e MONGO_INITDB_ROOT_PASSWORD=$MONGODB_PASSWORD --detach mongo:$MONGODB_VERSION --port $MONGODB_PORT
docker run --name $MONGODB_CONTAINER_NAME --publish $MONGODB_PORT:$MONGODB_PORT -e MONGO_INITDB_DATABASE=$MONGODB_DB -e MONGO_INITDB_ROOT_USERNAME=$MONGODB_USERNAME -e MONGO_INITDB_ROOT_PASSWORD=$MONGODB_PASSWORD --detach $MONGODB_IMAGE:$MONGODB_VERSION --port $MONGODB_PORT

if [ $? -ne 0 ]; then
echo "Error starting MongoDB Docker container"
Expand All @@ -121,7 +131,7 @@ echo " - replica set [$MONGODB_REPLICA_SET]"
echo ""


docker run --name $MONGODB_CONTAINER_NAME --publish $MONGODB_PORT:$MONGODB_PORT --detach mongo:$MONGODB_VERSION --port $MONGODB_PORT --replSet $MONGODB_REPLICA_SET
docker run --name $MONGODB_CONTAINER_NAME --publish $MONGODB_PORT:$MONGODB_PORT --detach $MONGODB_IMAGE:$MONGODB_VERSION --port $MONGODB_PORT --replSet $MONGODB_REPLICA_SET

if [ $? -ne 0 ]; then
echo "Error starting MongoDB Docker container"
Expand Down
Loading