Skip to content

Commit

Permalink
feat: Initial version (#1)
Browse files Browse the repository at this point in the history
* docs(README): remove WIP note

* build(package): initial version

* build(package): lock file

* build(gitignore): node_modules

* feat: initial version

* docs(README): badges

* docs(README): usage

* ci(release): initial version

* ci(test): initial version

* feat(script): add implementation to sync pull request merge options

https://docs.github.com/en/github/administering-a-repository/configuring-pull-request-merges

* docs(readme): update script usage with --template flag

* docs(readme): add links to repos used as inspiration

* chore(package.json): update description in package.json

* docs(README): add a new inspirational repository
  • Loading branch information
oscard0m committed Jun 2, 2021
1 parent 89c0098 commit 2cf5c0a
Show file tree
Hide file tree
Showing 8 changed files with 1,112 additions and 3 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Release
on:
push:
branches:
- main

jobs:
release:
name: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 12
- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
37 changes: 37 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Test
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize]

jobs:
test_matrix:
runs-on: ubuntu-latest
strategy:
matrix:
node_version: ["12", "14"]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node_version }}
- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- run: npm test

# The "test" step can be required in branch protection and does not
# change each time the test matrix changes.
test:
runs-on: ubuntu-latest
needs: test_matrix
steps:
- run: echo ok
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
39 changes: 36 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,41 @@
# 🚧 WORK IN PROGRESS. See [#1](https://github.com/oscard0m/octoherd-script-sync-repo-settings/pull/1) | [Preview](https://github.com/oscard0m/octoherd-script-sync-repo-settings/tree/initial-version)

# octoherd-script-sync-repo-settings

> This script takes settings in a .github/sync-repo-settings.yaml file, and automatically applies them to your repository
> This script takes [Repository Options](https://docs.github.com/en/github/administering-a-repository/configuring-pull-request-merges) from a Repository passed as argument and is used as template to apply same Options for other repositories.
[![@latest](https://img.shields.io/npm/v/octoherd-script-sync-repo-settings.svg)](https://www.npmjs.com/package/octoherd-script-sync-repo-settings)
[![Build Status](https://github.com/oscard0m/octoherd-script-sync-repo-settings/workflows/Test/badge.svg)](https://github.com/oscard0m/octoherd-script-sync-repo-settings/actions?query=workflow%3ATest+branch%3Amain)

## Usage

Minimal usage

```js
$ npx octoherd-script-sync-repo-settings \
--template "octoherd/cli"
```

Pass all options as CLI flags to avoid user prompts

```js
npx octoherd-script-sync-repo-settings \
--template "octoherd/cli" \
-T ghp_0123456789abcdefghjklmnopqrstuvwxyzA \
-R "oscard0m/*"
```

## Options

| option | type | description |
| ---------------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--template` | string | **Required.** Repository name from where to copy the branch protection settings. Example: `--template "octoherd/cli"` |
| `--octoherd-token`, `-T` | string | A personal access token ([create](https://github.com/settings/tokens/new?scopes=repo)). Script will create one if option is not set |
| `--octoherd-repos`, `-R` | array of strings | One or multiple space-separated repositories in the form of `repo-owner/repo-name`. `repo-owner/*` will find all repositories for one owner. `*` will find all repositories the user has access to. Will prompt for repositories if not set |
| `--octoherd-bypass-confirms` | boolean | Bypass prompts to confirm mutating requests |

## Inspired by
* https://github.com/octoherd/script-sync-branch-protections
* https://github.com/googleapis/repo-automation-bots/tree/master/packages/sync-repo-settings
* https://github.com/MunifTanjim/octoherd-script-set-pr-merge-config

## Contributing

Expand Down
6 changes: 6 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env node

import { script } from "./script.js";
import { run } from "@octoherd/cli/run";

run(script);
Loading

0 comments on commit 2cf5c0a

Please sign in to comment.