Skip to content

Commit

Permalink
Initial build of action.
Browse files Browse the repository at this point in the history
Signed-off-by: Chris. Webster <[email protected]>
  • Loading branch information
webstech committed Sep 20, 2022
1 parent e880058 commit 8a2d0eb
Show file tree
Hide file tree
Showing 17 changed files with 71,907 additions and 1 deletion.
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true

# Matches multiple files with brace expansion notation
# Set default charset
[*.ts]
charset = utf-8
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
max_line_length = 120
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist/
lib/
node_modules/
123 changes: 123 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
module.exports = {
"env": {
"es6": true,
"node": true
},
"extends": [
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"prettier"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json",
"sourceType": "module"
},
"plugins": [
"anti-trojan-source",
"@typescript-eslint"
],
"rules": {
"@typescript-eslint/array-type": [
"error",
{
"default": "array-simple"
}
],
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/dot-notation": "error",
"@typescript-eslint/naming-convention": [
"error",
{
"format": [
"camelCase",
"snake_case"
],
"selector": "variable"
}
],
"@typescript-eslint/no-unused-expressions": "error",
"@typescript-eslint/prefer-for-of": "error",
"@typescript-eslint/prefer-function-type": "error",
"@typescript-eslint/prefer-regexp-exec": "off",
"@typescript-eslint/restrict-template-expressions": "off",
"@typescript-eslint/triple-slash-reference": [
"error",
{
"lib": "always",
"path": "always",
"types": "prefer-import"
}
],
"@typescript-eslint/unified-signatures": "error",
"anti-trojan-source/no-bidi": "error",
"complexity": "off",
"constructor-super": "error",
"eqeqeq": [
"error",
"smart"
],
"guard-for-in": "error",
"id-blacklist": [
"error",
"any",
"Number",
"String",
"string",
"Boolean",
"boolean",
"Undefined",
"undefined"
],
"id-match": "error",
"max-classes-per-file": [
"error",
1
],
"max-len": [
"error",
{
"code": 120
}
],
"new-parens": "error",
"no-bitwise": "error",
"no-caller": "error",
"no-cond-assign": "error",
"no-console": "off",
"no-debugger": "error",
"no-empty": "error",
"no-eval": "error",
"no-fallthrough": "off",
"no-invalid-this": "off",
"no-new-wrappers": "error",
"no-shadow": [
"error",
{
"hoist": "never"
}
],
"no-throw-literal": "error",
"no-undef-init": "error",
"no-underscore-dangle": "error",
"no-unsafe-finally": "error",
"no-unused-labels": "error",
"object-shorthand": "error",
"one-var": [
"error",
"never"
],
"radix": "error",
"semi": "error",
"spaced-comment": [
"error",
"always",
{
"markers": [
"/"
]
}
],
"use-isnan": "error"
}
};
17 changes: 17 additions & 0 deletions .ghadocs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"paths": {
"action": "action.yml",
"readme": "README.md"
},
"show_logo": true,
"versioning": {
"enabled": "true",
"override": "",
"prefix": "v",
"branch": "main"
},
"owner": "gitgitgadget",
"repo": "check-status",
"title_prefix": "gitgitgadget Action: ",
"pretty": true
}
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* eol=lf
*.png -eol -text binary
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
labels:
- "dependencies"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
lib/
node_modules/
build/
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/
build/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Peter Evans

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
120 changes: 119 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,119 @@
# check-status
<!-- start title -->

# gitgitgadget Action: check-status

<!-- end title -->
<!-- start description -->

This is a GitHub action to perform various scheduled actions with projects using gitgitgadget to submit changes. It is used as a scheduled action running in a separate repo or the repo it is acting upon. The use case is for repos that will not allow complex GitHub actions in the codebase when the GitHub repo is a clone that is used to submit updates to a non-GitHub maintained repo.

<!-- end description -->
<!-- start contents -->
<!-- end contents -->

## Usage

<!-- start usage -->

```yaml
- uses: gitgitgadget/[email protected]
with:
# The action to be performed. It must be one of the following: "update-open-prs",
# "update-commit-mappings", "handle-open-prs", "handle-new-mails".
action: ""

# Repository owner.
repo-owner: ""

# Repository name.
repo-name: ""

# A repo scoped GitHub Personal Access Token.
token: ""

# The location of the repository.
repository-dir: ""

# The location of the repository with gitgitgadget configuration information. This
# would be used in place of the `config` parameter for the `git` repository. This
# is normally the gitgitgadget repo with any needed configuration settings. Most
# users will specify a `config`.
config-repository-dir: ""

# JSON configuration for commands.
config: ""
```
<!-- end usage -->
## Inputs
<!-- start inputs -->
| **Input** | **Description** | **Default** | **Required** |
| :-------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :---------: | :----------: |
| **`action`** | The action to be performed. It must be one of the following: "update-open-prs", "update-commit-mappings", "handle-open-prs", "handle-new-mails". | | **true** |
| **`repo-owner`** | Repository owner. | | **true** |
| **`repo-name`** | Repository name. | | **true** |
| **`token`** | A repo scoped GitHub Personal Access Token. | | **true** |
| **`repository-dir`** | The location of the repository. | | **true** |
| **`config-repository-dir`** | The location of the repository with gitgitgadget configuration information. This would be used in place of the `config` parameter for the `git` repository. This is normally the gitgitgadget repo with any needed configuration settings. Most users will specify a `config`. | | **false** |
| **`config`** | JSON configuration for commands. | | **true** |

<!-- end inputs -->
<!-- start outputs -->
<!-- end outputs -->
<!-- start [.github/ghdocs/examples/] -->
<!-- end [.github/ghdocs/examples/] -->

## Contributing

### Environment

The rebuild of this document (README.md) expects a `docker`
command is available from the command line.

### Building

#### action.yml changes

Changes to `action.yml` require rebuilding the `README.md`. This is done
using `npm run build:readme`. **Note**: markup is very limited in the
`action.yml`.

#### Source changes

Before making source changes, the `gitgitgadget` package must be built and
installed. Other packages must also be installed but the
`gitgitgadget` package is not available on npm.

1. In the `gitgitgadget` repo run `npm pack` to generate the package.
1. Run `npm install gitgitgadget` to install the package locally. This
assumes the two repos are at the same directory level.

Code changes are built using `npm run build`. This builds a new action in the
`dist` directory.

### Testing

The action supports four different checks. The checks and associated npm
commands are:

- update-open-prs (test:upr)
- update-commit-mappings (test:ucm)
- handle-open-prs (test:hop)
- handle-new-mails (test:hnm)

A windows command is provided for testing. It requires:

1. A test repo set up to be monitored. A GitHub PAT must already be set as
the INPUT_TOKEN environment variable or indentifed in a `.secret` file in
the repo. The format of the `.secret` file is `INPUT_TOKEN=<pat>`.
2. A config describing the test repo.
3. For testing mail checks, a mail repo must be available with valid email.

The test is run using the command:

```
npm run <test-name> <test-repo-owner> <test-repo-name> <config-location> <email-repo-location>
```
48 changes: 48 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: check-status
author: webstech
description: >
This is a GitHub action to perform various scheduled actions with projects
using gitgitgadget to submit changes. It is used as a scheduled action
running in a separate repo or the repo it is acting upon. The use case
is for repos that will not allow complex GitHub actions in the codebase
when the GitHub repo is a clone that is used to submit updates to a
non-GitHub maintained repo.
inputs:
action:
description: >
The action to be performed. It must be one of the following:
"update-open-prs",
"update-commit-mappings",
"handle-open-prs",
"handle-new-mails".
required: true
repo-owner:
description: Repository owner.
required: true
repo-name:
description: Repository name.
required: true
token:
description: A repo scoped GitHub Personal Access Token.
required: true
repository-dir:
description: The location of the repository.
required: true
config-repository-dir:
description: The location of the repository with gitgitgadget configuration
information. This would be used in place of the `config` parameter for
the `git` repository. This is normally the gitgitgadget repo with any
needed configuration settings. Most users will specify a `config`.
required: false
config:
description: JSON configuration for commands.
required: true

runs:
using: 'node16'
main: 'dist/index.js'

branding:
icon: 'check'
color: 'gray-dark'
Loading

0 comments on commit 8a2d0eb

Please sign in to comment.