Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/open-condo-software/gitexporter
Make some private GitHub repo directories public
https://github.com/open-condo-software/gitexporter
Last synced: about 2 months ago
JSON representation
Make some private GitHub repo directories public
- Host: GitHub
- URL: https://github.com/open-condo-software/gitexporter
- Owner: open-condo-software
- License: mit
- Created: 2021-12-04T09:55:45.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2024-03-12T14:32:46.000Z (9 months ago)
- Last Synced: 2024-10-01T14:48:29.423Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 143 KB
- Stars: 77
- Watchers: 1
- Forks: 3
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome - open-condo-software/gitexporter - Make some private GitHub repo directories public (JavaScript)
README
[![npm status](https://img.shields.io/npm/v/gitexporter?color=%2332c954&label=gitexporter&logo=gitexporter&logoColor=%23414851)](https://www.npmjs.com/package/gitexporter) [![gitexporter test status](https://github.com/open-condo-software/gitexporter/actions/workflows/node.js.yml/badge.svg?branch=master)](https://github.com/open-condo-software/gitexporter)
# gitexporter cli tool
You're in the right place if:
- Do you have an **open-source** project with an **open** and **closed part** and you want to **work in one git repo** without git submodules?
- Do you want to **public** some **private** GitHub **repo directories**?
- You want to **keep** the **authorship** and **history** of the **comments**
- You don't want to use git submodulesOthers cases:
- You are developing in a git mono repository and want to open-source some directories
- You are developing some OpenSource project and want to disallow open some secret files# how it works ?
`gitexporter` create a new git repo from your existing repository with only allowed public files and dirs.
The `gitexporter` goes through the git commit tree and adds to a new repo only the allowed files.
# Example
- `/` -- monorepository root
- `/apps/service1` -- it's open source
- `/apps/optional-secure-service2` -- it's closed source
- `/gitexporter.config.json` -- git exporter config file`gitexporter.config.json`
```
{
"forceReCreateRepo": true,
"targetRepoPath": "my-open-source-repo",
"sourceRepoPath": ".",
"allowedPaths": ["apps/service1/*"],
"ignoredPaths": ["apps/service1/.env", "apps/optional-secure-service2", "gitexporter.config.json"]
}
```Just run `npx gitexporter gitexporter.config.json` and you will get a new git repository with just `apps/service1` directory.
# GITHUB ACTIONS CI EXAMPLE
1. create a new user: `sync-bot`
2. add new user ssh keys `SSH_SYNC_BOT_PRIVATE_KEY`: https://github.com/settings/keys
3. add the user to `org/private` and `org/open` repo
4. add `SSH_SYNC_BOT_PRIVATE_KEY` to `org/private` repo
5. add CI files to `org/private` repo:`.github/workflows/gitexporter.yml`
```yaml
name: gitexporter
on:
push:
branches:
- 'master'jobs:
gitexporter:
name: Gitexporter
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ssh-key: ${{ secrets.SSH_SYNC_BOT_PRIVATE_KEY }}
- name: Checkout org/private
uses: actions/checkout@v2
with:
repository: 'org/private'
fetch-depth: 0
submodules: recursive
ssh-key: ${{ secrets.SSH_SYNC_BOT_PRIVATE_KEY }}
path: gitexporter.source
ref: 'master'
- name: Checkout org/open
uses: actions/checkout@v2
with:
repository: 'org/open'
fetch-depth: 0
submodules: recursive
ssh-key: ${{ secrets.SSH_SYNC_BOT_PRIVATE_KEY }}
path: gitexporter.target
ref: 'master'
- name: gitexporter.sh
run: |
bash .github/workflows/gitexporter.sh gitexporter.source gitexporter.target
cat gitexporter.source.log.json
```
`.github/workflows/gitexporter.sh`
```bash
#!/usr/bin/env bash
set -eo pipefailif [[ -z "$1" || -z "$2" ]]; then
echo "use $0 "
exit 2
fiSOURCE_FOLDER=$1
TARGET_FOLDER=$2echo "[GITEXPORTER]"
cat > ${SOURCE_FOLDER}.config.json <