Skip to content

Commit

Permalink
feat: Ory-specific GitHub action for conventional commits (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevgo committed Jul 27, 2022
1 parent 1200c00 commit 182a317
Show file tree
Hide file tree
Showing 22 changed files with 16,024 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Tests

on:
pull_request:
types:
- opened
- reopened
push:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- id: cache-node
uses: actions/cache@v3
with:
path: conventional_commit_config/node_modules
key:
${{ runner.os }}-cococo-node-${{
hashFiles('conventional_commit_config/package-lock.json') }}
- run: npm ci --legacy-peer-deps
if: steps.cache-node.outputs.cache-hit != 'true'
- run: cd conventional_commit_config && npm run test
2 changes: 2 additions & 0 deletions conventional_commit_config/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
lib
19 changes: 19 additions & 0 deletions conventional_commit_config/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
root: true,
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
env: {
node: true,
},
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
"prettier",
],
rules: {
"no-var": 0,
"import/order": ["error", { alphabetize: { order: "asc" } }],
},
}
2 changes: 2 additions & 0 deletions conventional_commit_config/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
lib/
node_modules/
5 changes: 5 additions & 0 deletions conventional_commit_config/.mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"spec": "src/**/*.test.ts",
"ui": "tdd",
"require": "ts-node/register"
}
2 changes: 2 additions & 0 deletions conventional_commit_config/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/
lib/
37 changes: 37 additions & 0 deletions conventional_commit_config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Conventional Commits GitHub Action

This Github Action is only used in
https://github.com/ory/meta/blob/master/templates/repository/common/.github/workflows/conventional_commits.yml.
It allows individual repositories to override the default scopes for
conventional commits via a config file.

This config file must be at `.github/conventional_commits.json` in your
repository and have content that looks like this:

```json
{
"$schema": "https://raw.githubusercontent.com/ory/ci/master/conventional_commit_config/dist/config.schema.json",
"types": ["type1", "type2"],
"addTypes": ["type3", "type4"],
"scopes": ["scope1", "scope2"],
"addScopes": ["scope3", "scope4"],
"requireScope": true
}
```

You never need all options together. Set only the ones you need.

| name | description | default |
| -------------- | -------------------------------------------------- | ------- |
| _types_ | overrides the default types | `[]` |
| _addTypes_ | adds the given types to the set of default types | `[]` |
| _scopes_ | overrides the default scopes | `[]` |
| _addScopes_ | adds the given scopes to the set of default scopes | `[]` |
| _requireScope_ | enforces a scope in pull requests titles | `false` |

### Development

GitHub Actions don't run `npm install` in production. This GitHub Actions
therefore bundles external production dependencies into `dist/index.js`. To keep
this file up to date, please remember to run `npm run build` before committing.
Otherwise, your changes won't show up in production.
28 changes: 28 additions & 0 deletions conventional_commit_config/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Conventional commits configuration
description: determines the configuration for conventional commits

inputs:
config_path:
description: path of the config file
required: true
default_types:
description: the default types to use
required: true
default_scopes:
description: the default scopes to use
required: true
default_require_scope:
description: whether to require scopes by default
required: true

outputs:
types:
description: the types to use
scopes:
description: the scopes to use
requireScope:
description: whether to require scopes by default

runs:
using: node16
main: dist/index.js
45 changes: 45 additions & 0 deletions conventional_commit_config/dist/config.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"description": "data format of the configuration file",
"properties": {
"$schema": {
"description": "link to JSON schema",
"type": "string"
},
"addScopes": {
"description": "add to the default scopes",
"items": {
"type": "string"
},
"type": "array"
},
"addTypes": {
"description": "add to the default types",
"items": {
"type": "string"
},
"type": "array"
},
"requireScope": {
"description": "whether to enforce a scope in pull request titles",
"type": "boolean"
},
"scopes": {
"description": "override the default scopes",
"items": {
"type": "string"
},
"type": "array"
},
"types": {
"description": "override the default types",
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
}

Loading

0 comments on commit 182a317

Please sign in to comment.