Skip to content

Commit

Permalink
Merge pull request #9 from actalog/v2
Browse files Browse the repository at this point in the history
V2
  • Loading branch information
gabrielrufino authored Dec 7, 2024
2 parents 878c057 + 5f3b958 commit 2671067
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml → .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Release
name: CD

on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+
- v*

permissions:
contents: write
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
- uses: ./
with:
connection-string: mongodb://root:root@database:27017
output-password: '12345678'
- uses: actions/upload-artifact@v4
with:
name: dump-mongo${{ matrix.mongo-version }}
Expand Down
49 changes: 38 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,56 @@
# Mongodump

GitHub Action for creating a binary export of a database's contents
A GitHub Action to create MongoDB backups efficiently and securely, using `mongodump` with password-protected compression.

## Example usage
## Features

```yml
- 🛡️ **Secure Backups**: Password-protected compressed backups for enhanced data security.
- 🔄 **Simple Automation**: Automatically generate backups during CI/CD pipelines.
- 🚀 **Docker-Based**: Lightweight and easy to use.
- 📦 **Compatible with MongoDB 6**.

---

## Usage

### 1. Workflow Configuration

Add this Action to your GitHub workflow in the `.github/workflows/workflow.yml` file:

```yaml
name: Backup

on:
schedule:
- cron: 0 0 * * *

jobs:
backup:
mongodump:
name: Mongodump
runs-on: ubuntu-latest
steps:
- uses: actalog/mongodump@v1
with:
connection-string: ${{ secrets.MONGO_URI }}
- uses: actions/upload-artifact@v4
with:
name: dump
path: ${{ github.workspace }}/dump
connection-string: ${{ secrets.CONNECTION_STRING }}
output-password: ${{ secrets.OUTPUT_PASSWORD }}
```
## Security
### 2. Action Inputs
| Parameter | Required | Description |
|---------------------|----------|-----------------------------------------------------|
| `connection-string` | Yes | MongoDB connection URI (stored as a secret). |
| `output-password` | Yes | Password to protect the backup file. |

### 3. Setting Up Secrets

Add the following secrets to your GitHub repository:

1. **`CONNECTION_STRING`**: The connection URI for your MongoDB instance.
2. **`OUTPUT_PASSWORD`**: The password to secure the backup file.

---

## License

Remember that artifacts can be downloaded by anyone who has the artifact download link or access to the workflow run. Which means that you need to use a private repository if you want create backups and upload them as artifacts.
This project is licensed under the terms of [The Unlicense](./LICENSE).
12 changes: 7 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
name: '@actalog/mongodump'
description: GitHub Action for creating a binary export of a database's contents
description: Creates a binary export of a database's contents
branding:
icon: 'database'
color: 'green'

inputs:
connection-string:
required: true
output-password:
required: true

runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.connection-string }}

branding:
icon: 'database'
color: 'green'
- ${{ inputs.output-password }}
9 changes: 8 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#!/bin/sh -l

apt update && apt upgrade -y
apt install zip -y

cd /action
mongodump $1

zip -P $2 -r dump.zip dump
rm -rf dump

mkdir $GITHUB_WORKSPACE/dump
cp -r dump $GITHUB_WORKSPACE/dump
cp -r dump.zip $GITHUB_WORKSPACE/dump

0 comments on commit 2671067

Please sign in to comment.